mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 01:04:06 +00:00
Add workaround to turn off nursery size heuristic
SpiderMonkey 98 introduced a size heuristic for the nursery GC region (https://phabricator.services.mozilla.com/D136637). As this heuristic uses a wall-clock time duration, it results in a severe performance regression on slower systems for our use case. This commit adds a workaround to turn off that heuristic, by telling SpiderMonkey that a "page load" (something which doesn't have a meaning in the context of pyrogenesis) is in progress, as that heuristic is disabled for page loads. Co-Authored by: Ralph Sennhauser <ralph.sennhauser@gmail.com> Fixes #7714
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
#include "scriptinterface/ScriptEngine.h"
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
|
||||
#include "js/friend/PerformanceHint.h"
|
||||
|
||||
void GCSliceCallbackHook(JSContext* UNUSED(cx), JS::GCProgress progress, const JS::GCDescription& UNUSED(desc))
|
||||
{
|
||||
/**
|
||||
@@ -127,6 +129,10 @@ ScriptContext::ScriptContext(int contextSize, int heapGrowthBytesGCTrigger):
|
||||
JS_SetGlobalJitCompilerOption(m_cx, JSJITCOMPILER_SPECTRE_STRING_MITIGATIONS, 0);
|
||||
JS_SetGlobalJitCompilerOption(m_cx, JSJITCOMPILER_SPECTRE_OBJECT_MITIGATIONS, 0);
|
||||
|
||||
// Workaround to turn off nursery size heuristic.
|
||||
// See https://gitea.wildfiregames.com/0ad/0ad/issues/7714 for details.
|
||||
js::gc::SetPerformanceHint(m_cx, js::gc::PerformanceHint::InPageLoad);
|
||||
|
||||
ScriptEngine::GetSingleton().RegisterContext(m_cx);
|
||||
|
||||
JS::SetJobQueue(m_cx, m_JobQueue.get());
|
||||
@@ -137,6 +143,9 @@ ScriptContext::~ScriptContext()
|
||||
{
|
||||
ENSURE(ScriptEngine::IsInitialised() && "The ScriptEngine must be active (initialized and not yet shut down) when destroying a ScriptContext!");
|
||||
|
||||
// Switch back to normal performance mode to avoid assertion in debug mode.
|
||||
js::gc::SetPerformanceHint(m_cx, js::gc::PerformanceHint::Normal);
|
||||
|
||||
JS_DestroyContext(m_cx);
|
||||
ScriptEngine::GetSingleton().UnRegisterContext(m_cx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user