mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-12 04:57:06 -04:00
Remove huge TLS variable; fixes Linux issues
Randomizer code was allocating a 25MB buffer for file I/O using thread-local storage, which was starving the stack space of threads created on Linux. The buffer appears to be a workaround for Wii U homebrew I/O, so we can just disable it altogether. Resolves #1836
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
#include "../utility/log.hpp"
|
||||
#include "../utility/path.hpp"
|
||||
#include "../utility/platform.hpp"
|
||||
#ifdef DEVKITPRO
|
||||
#include "../utility/thread_local.hpp"
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include <regex>
|
||||
@@ -31,6 +33,7 @@ namespace randomizer::utility::file
|
||||
return false;
|
||||
};
|
||||
|
||||
#ifdef DEVKITPRO
|
||||
static constexpr int FILE_BUF_SIZE = 25 * 1024 * 1024;
|
||||
class AlignedBufferWrapper
|
||||
{
|
||||
@@ -41,6 +44,7 @@ namespace randomizer::utility::file
|
||||
char* getBuffer() { return buffer; }
|
||||
};
|
||||
static ThreadLocal<AlignedBufferWrapper, DataIDs::FILE_OP_BUFFER> buf;
|
||||
#endif
|
||||
|
||||
bool copy_file(const fspath& from, const fspath& to)
|
||||
{
|
||||
@@ -189,11 +193,15 @@ namespace randomizer::utility::file
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef DEVKITPRO
|
||||
while (file)
|
||||
{
|
||||
file.read(buf.get().getBuffer(), FILE_BUF_SIZE);
|
||||
fileContents.write(buf.get().getBuffer(), file.gcount());
|
||||
}
|
||||
#else
|
||||
fileContents << file.rdbuf();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user