forked from mirrors/0ad
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
(cherry picked from commit 11dd480b67)
Signed-off-by: Itms <itms@wildfiregames.com>
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))
|
||||
{
|
||||
/**
|
||||
@@ -129,6 +131,10 @@ ScriptContext::ScriptContext(int contextSize, int heapGrowthBytesGCTrigger):
|
||||
|
||||
JS::ContextOptionsRef(m_cx).setStrictMode(true);
|
||||
|
||||
// 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());
|
||||
@@ -139,6 +145,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