Increase thresholds for small function compilation and warm-up to optimize performance for jQuery-style code.

This commit is contained in:
ownedbywuigi 2026-03-28 09:20:54 +00:00
commit 2dd5267098
3 changed files with 38 additions and 28 deletions

View file

@ -47,8 +47,11 @@ OptimizationInfo::initNormalOptimizationInfo()
scalarReplacement_ = true;
smallFunctionMaxInlineDepth_ = 10;
compilerWarmUpThreshold_ = CompilerWarmupThreshold;
compilerSmallFunctionWarmUpThreshold_ = CompilerSmallFunctionWarmupThreshold;
inliningWarmUpThresholdFactor_ = 0.10;
// Start compiling tiny helper functions sooner. This is particularly
// useful for jQuery-style code with many frequently-called short helpers.
compilerSmallFunctionWarmUpThreshold_ = 32;
// Inline callees a bit earlier once a script becomes warm.
inliningWarmUpThresholdFactor_ = 0.08;
inliningRecompileThresholdFactor_ = 4;
}
@ -112,6 +115,16 @@ OptimizationInfo::compilerWarmUpThreshold(JSScript* script, jsbytecode* pc) cons
warmUpThreshold *= ratio;
}
// jQuery spends a lot of time in medium-small wrappers that are too large
// to be classified as "small" but still hot enough to benefit from Ion.
// Nudge these scripts toward earlier compilation without affecting large
// scripts that are expensive to optimize.
if (script->length() <= 400 && numLocalsAndArgs <= 48) {
warmUpThreshold = (warmUpThreshold * 3) / 4;
if (warmUpThreshold < 30)
warmUpThreshold = 30;
}
if (!pc || JitOptions.eagerCompilation)
return warmUpThreshold;

View file

@ -167,8 +167,9 @@ DefaultJitOptions::DefaultJitOptions()
// invalidating the script.
SET_DEFAULT(osrPcMismatchesBeforeRecompile, 6000);
// The bytecode length limit for small function.
SET_DEFAULT(smallFunctionMaxBytecodeLength_, 200);
// The bytecode length limit for small function. jQuery has many helpers
// just above 200 bytecodes, so raise this to compile them sooner.
SET_DEFAULT(smallFunctionMaxBytecodeLength_, 320);
// An artificial testing limit for the maximum supported offset of
// pc-relative jump and call instructions.