mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1476405: Part 3 - Use reasonable stack sizes and create wrappers for JS threads. r=erahm,tcampbell
For ordinary JS helper threads, we can update names and create wrappers using the existing thread profiler hooks, but we still need to update their default stack sizes to avoid huge pages. For the XPConnect JS Watchdog thread, we sometimes get a wrapper as it is, but only sometimes. And we never use a reasonable stack size. MozReview-Commit-ID: EuR3gL5JATL --HG-- extra : rebase_source : 99985a751a37fb8c515cea8cdae4526b319aba67 extra : intermediate-source : 4831cbfd03ded9ea6dcc8d6f0797f5f80fb717c7 extra : source : f092a32a363911e58c71ed5d2e4bd92347437c7e
This commit is contained in:
parent
6bde5d95f3
commit
7c7c5fb182
@ -943,7 +943,12 @@ js::CurrentThreadIsParseThread()
|
||||
}
|
||||
#endif
|
||||
|
||||
static const uint32_t kDefaultHelperStackSize = 2048 * 1024;
|
||||
// We want our default stack size limit to be approximately 2MB, to be safe, but
|
||||
// expect most threads to use much less. On Linux, however, requesting a stack
|
||||
// of 2MB or larger risks the kernel allocating an entire 2MB huge page for it
|
||||
// on first access, which we do not want. To avoid this possibility, we subtract
|
||||
// 2 standard VM page sizes from our default.
|
||||
static const uint32_t kDefaultHelperStackSize = 2048 * 1024 - 2 * 4096;
|
||||
static const uint32_t kDefaultHelperStackQuota = 1800 * 1024;
|
||||
|
||||
// TSan enforces a minimum stack size that's just slightly larger than our
|
||||
|
@ -79,6 +79,10 @@ using namespace xpc;
|
||||
using namespace JS;
|
||||
using mozilla::dom::AutoEntryScript;
|
||||
|
||||
// The watchdog thread loop is pretty trivial, and should not require much stack
|
||||
// space to do its job. So only give it 32KiB.
|
||||
static constexpr size_t kWatchdogStackSize = 32 * 1024;
|
||||
|
||||
static void WatchdogMain(void* arg);
|
||||
class Watchdog;
|
||||
class WatchdogManager;
|
||||
@ -143,7 +147,7 @@ class Watchdog
|
||||
// join it on shutdown.
|
||||
mThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this,
|
||||
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
|
||||
PR_JOINABLE_THREAD, 0);
|
||||
PR_JOINABLE_THREAD, kWatchdogStackSize);
|
||||
if (!mThread)
|
||||
MOZ_CRASH("PR_CreateThread failed!");
|
||||
|
||||
@ -472,6 +476,8 @@ static void
|
||||
WatchdogMain(void* arg)
|
||||
{
|
||||
AUTO_PROFILER_REGISTER_THREAD("JS Watchdog");
|
||||
// Create an nsThread wrapper for the thread and register it with the thread manager.
|
||||
Unused << NS_GetCurrentThread();
|
||||
NS_SetCurrentThreadName("JS Watchdog");
|
||||
|
||||
Watchdog* self = static_cast<Watchdog*>(arg);
|
||||
|
Loading…
Reference in New Issue
Block a user