Changeset 203318 in webkit
- Timestamp:
- Jul 15, 2016, 7:12:31 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/bytecode/CodeBlock.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/Options.h (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/Scripts/run-jsc-stress-tests (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r203315 r203318 1 2016-07-15 Benjamin Poulain <bpoulain@apple.com> 2 3 [JSC] Change some parameters based on a random search 4 https://bugs.webkit.org/show_bug.cgi?id=158514 5 6 Reviewed by Saam Barati. 7 8 * bytecode/CodeBlock.cpp: 9 (JSC::CodeBlock::optimizationThresholdScalingFactor): 10 * runtime/Options.h: 11 1 12 2016-07-15 Mark Lam <mark.lam@apple.com> 2 13 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r203239 r203318 3694 3694 double CodeBlock::optimizationThresholdScalingFactor() 3695 3695 { 3696 // This expression arises from doing a least-squares fit of 3697 // 3698 // F[x_] =: a * Sqrt[x + b] + Abs[c * x] + d 3699 // 3700 // against the data points: 3701 // 3702 // x F[x_] 3703 // 10 0.9 (smallest reasonable code block) 3704 // 200 1.0 (typical small-ish code block) 3705 // 320 1.2 (something I saw in 3d-cube that I wanted to optimize) 3706 // 1268 5.0 (something I saw in 3d-cube that I didn't want to optimize) 3707 // 4000 5.5 (random large size, used to cause the function to converge to a shallow curve of some sort) 3708 // 10000 6.0 (similar to above) 3709 // 3710 // I achieve the minimization using the following Mathematica code: 3711 // 3712 // MyFunctionTemplate[x_, a_, b_, c_, d_] := a*Sqrt[x + b] + Abs[c*x] + d 3713 // 3714 // samples = {{10, 0.9}, {200, 1}, {320, 1.2}, {1268, 5}, {4000, 5.5}, {10000, 6}} 3715 // 3716 // solution = 3717 // Minimize[Plus @@ ((MyFunctionTemplate[#[[1]], a, b, c, d] - #[[2]])^2 & /@ samples), 3718 // {a, b, c, d}][[2]] 3719 // 3720 // And the code below (to initialize a, b, c, d) is generated by: 3721 // 3722 // Print["const double " <> ToString[#[[1]]] <> " = " <> 3723 // If[#[[2]] < 0.00001, "0.0", ToString[#[[2]]]] <> ";"] & /@ solution 3724 // 3725 // We've long known the following to be true: 3726 // - Small code blocks are cheap to optimize and so we should do it sooner rather 3727 // than later. 3728 // - Large code blocks are expensive to optimize and so we should postpone doing so, 3729 // and sometimes have a large enough threshold that we never optimize them. 3730 // - The difference in cost is not totally linear because (a) just invoking the 3731 // DFG incurs some base cost and (b) for large code blocks there is enough slop 3732 // in the correlation between instruction count and the actual compilation cost 3733 // that for those large blocks, the instruction count should not have a strong 3734 // influence on our threshold. 3735 // 3736 // I knew the goals but I didn't know how to achieve them; so I picked an interesting 3737 // example where the heuristics were right (code block in 3d-cube with instruction 3738 // count 320, which got compiled early as it should have been) and one where they were 3739 // totally wrong (code block in 3d-cube with instruction count 1268, which was expensive 3740 // to compile and didn't run often enough to warrant compilation in my opinion), and 3741 // then threw in additional data points that represented my own guess of what our 3742 // heuristics should do for some round-numbered examples. 3743 // 3744 // The expression to which I decided to fit the data arose because I started with an 3745 // affine function, and then did two things: put the linear part in an Abs to ensure 3746 // that the fit didn't end up choosing a negative value of c (which would result in 3747 // the function turning over and going negative for large x) and I threw in a Sqrt 3748 // term because Sqrt represents my intution that the function should be more sensitive 3749 // to small changes in small values of x, but less sensitive when x gets large. 3750 3751 // Note that the current fit essentially eliminates the linear portion of the 3752 // expression (c == 0.0). 3753 const double a = 0.061504; 3754 const double b = 1.02406; 3755 const double c = 0.0; 3756 const double d = 0.825914; 3757 3696 // We want a good threshold based on the instruction count. 3697 // Here, we are trying to optimize the following formula: 3698 // F[x_] =: a * Sqrt[x + b] + Abs[c * x] + d 3699 // The parameters were chosen by testing random values 3700 // between 1 and 2 and keeping the best combination. 3701 const double a = Options::optimizationThresholdScalingFactorA(); 3702 const double b = Options::optimizationThresholdScalingFactorB(); 3703 const double c = Options::optimizationThresholdScalingFactorC(); 3704 const double d = Options::optimizationThresholdScalingFactorD(); 3705 3758 3706 double instructionCount = this->instructionCount(); 3759 3707 -
trunk/Source/JavaScriptCore/runtime/Options.h
r203142 r203318 98 98 unsigned m_highLimit; 99 99 }; 100 101 #if CPU(X86_64) 102 constexpr int32_t archThresholdForJITAfterWarmUp = 610; 103 constexpr int32_t archThresholdForJITSoon = 89; 104 constexpr int32_t archThresholdForOptimizeAfterWarmUp = 864; 105 constexpr int32_t archThresholdForOptimizeAfterLongWarmUp = 1489; 106 constexpr int32_t archThresholdForOptimizeSoon = 864; 107 constexpr int32_t archExecutionCounterIncrementForLoop = 2; 108 constexpr int32_t archExecutionCounterIncrementForEntry = 16; 109 constexpr int32_t archThresholdForFTLOptimizeAfterWarmUp = 109160; 110 constexpr int32_t archThresholdForFTLOptimizeSoon = 825; 111 constexpr int32_t archFtlTierUpCounterIncrementForLoop = 8; 112 constexpr int32_t archFtlTierUpCounterIncrementForReturn = 27; 113 constexpr unsigned archFtlOSREntryRetryThreshold = 109; 114 constexpr double archOptimizationThresholdScalingFactorA = 0.0258587392234135; 115 constexpr double archOptimizationThresholdScalingFactorB = 1.2428014544978696; 116 constexpr double archOptimizationThresholdScalingFactorC = 0.0013276440240339; 117 constexpr double archOptimizationThresholdScalingFactorD = 1.3130654609331458; 118 constexpr int32_t archEvalThresholdMultiplier = 12; 119 #else 120 constexpr int32_t archThresholdForJITAfterWarmUp = 500; 121 constexpr int32_t archThresholdForJITSoon = 100; 122 constexpr int32_t archThresholdForOptimizeAfterWarmUp = 1000; 123 constexpr int32_t archThresholdForOptimizeAfterLongWarmUp = 1000; 124 constexpr int32_t archThresholdForOptimizeSoon = 1000; 125 constexpr int32_t archExecutionCounterIncrementForLoop = 1; 126 constexpr int32_t archExecutionCounterIncrementForEntry = 15; 127 constexpr int32_t archThresholdForFTLOptimizeAfterWarmUp = 100000; 128 constexpr int32_t archThresholdForFTLOptimizeSoon = 1000; 129 constexpr int32_t archFtlTierUpCounterIncrementForLoop = 1; 130 constexpr int32_t archFtlTierUpCounterIncrementForReturn = 15; 131 constexpr unsigned archFtlOSREntryRetryThreshold = 100; 132 constexpr double archOptimizationThresholdScalingFactorA = 0.061504; 133 constexpr double archOptimizationThresholdScalingFactorB = 1.02406; 134 constexpr double archOptimizationThresholdScalingFactorC = 0.0; 135 constexpr double archOptimizationThresholdScalingFactorD = 0.825914; 136 constexpr int32_t archEvalThresholdMultiplier = 10; 137 #endif 100 138 101 139 typedef OptionRange optionRange; … … 254 292 v(double, jitPolicyScale, 1.0, Normal, "scale JIT thresholds to this specified ratio between 0.0 (compile ASAP) and 1.0 (compile like normal).") \ 255 293 v(bool, forceEagerCompilation, false, Normal, nullptr) \ 256 v(int32, thresholdForJITAfterWarmUp, 500, Normal, nullptr) \257 v(int32, thresholdForJITSoon, 100, Normal, nullptr) \258 \ 259 v(int32, thresholdForOptimizeAfterWarmUp, 1000, Normal, nullptr) \260 v(int32, thresholdForOptimizeAfterLongWarmUp, 1000, Normal, nullptr) \261 v(int32, thresholdForOptimizeSoon, 1000, Normal, nullptr) \262 v(int32, executionCounterIncrementForLoop, 1, Normal, nullptr) \263 v(int32, executionCounterIncrementForEntry, 15, Normal, nullptr) \264 \ 265 v(int32, thresholdForFTLOptimizeAfterWarmUp, 100000, Normal, nullptr) \266 v(int32, thresholdForFTLOptimizeSoon, 1000, Normal, nullptr) \267 v(int32, ftlTierUpCounterIncrementForLoop, 1, Normal, nullptr) \268 v(int32, ftlTierUpCounterIncrementForReturn, 15, Normal, nullptr) \294 v(int32, thresholdForJITAfterWarmUp, archThresholdForJITAfterWarmUp, Normal, nullptr) \ 295 v(int32, thresholdForJITSoon, archThresholdForJITSoon, Normal, nullptr) \ 296 \ 297 v(int32, thresholdForOptimizeAfterWarmUp, archThresholdForOptimizeAfterWarmUp, Normal, nullptr) \ 298 v(int32, thresholdForOptimizeAfterLongWarmUp, archThresholdForOptimizeAfterLongWarmUp, Normal, nullptr) \ 299 v(int32, thresholdForOptimizeSoon, archThresholdForOptimizeSoon, Normal, nullptr) \ 300 v(int32, executionCounterIncrementForLoop, archExecutionCounterIncrementForLoop, Normal, nullptr) \ 301 v(int32, executionCounterIncrementForEntry, archExecutionCounterIncrementForEntry, Normal, nullptr) \ 302 \ 303 v(int32, thresholdForFTLOptimizeAfterWarmUp, archThresholdForFTLOptimizeAfterWarmUp, Normal, nullptr) \ 304 v(int32, thresholdForFTLOptimizeSoon, archThresholdForFTLOptimizeSoon, Normal, nullptr) \ 305 v(int32, ftlTierUpCounterIncrementForLoop, archFtlTierUpCounterIncrementForLoop, Normal, nullptr) \ 306 v(int32, ftlTierUpCounterIncrementForReturn, archFtlTierUpCounterIncrementForReturn, Normal, nullptr) \ 269 307 v(unsigned, ftlOSREntryFailureCountForReoptimization, 15, Normal, nullptr) \ 270 v(unsigned, ftlOSREntryRetryThreshold, 100, Normal, nullptr) \ 271 \ 272 v(int32, evalThresholdMultiplier, 10, Normal, nullptr) \ 308 v(unsigned, ftlOSREntryRetryThreshold, archFtlOSREntryRetryThreshold, Normal, nullptr) \ 309 \ 310 v(double, optimizationThresholdScalingFactorA, archOptimizationThresholdScalingFactorA, Normal, nullptr) \ 311 v(double, optimizationThresholdScalingFactorB, archOptimizationThresholdScalingFactorB, Normal, nullptr) \ 312 v(double, optimizationThresholdScalingFactorC, archOptimizationThresholdScalingFactorC, Normal, nullptr) \ 313 v(double, optimizationThresholdScalingFactorD, archOptimizationThresholdScalingFactorD, Normal, nullptr) \ 314 \ 315 v(int32, evalThresholdMultiplier, archEvalThresholdMultiplier, Normal, nullptr) \ 273 316 v(unsigned, maximumEvalCacheableSourceLength, 256, Normal, nullptr) \ 274 317 \ -
trunk/Tools/ChangeLog
r203284 r203318 1 2016-07-15 Benjamin Poulain <bpoulain@apple.com> 2 3 [JSC] Change some parameters based on a random search 4 https://bugs.webkit.org/show_bug.cgi?id=158514 5 6 Reviewed by Saam Barati. 7 8 * Scripts/run-jsc-stress-tests: 9 1 10 2016-07-15 Jon Davis <jond@apple.com> 2 11 -
trunk/Tools/Scripts/run-jsc-stress-tests
r203067 r203318 430 430 BASE_OPTIONS = ["--useFTLJIT=false", "--useFunctionDotArguments=true", "--maxPerThreadStackUsage=1572864"] 431 431 EAGER_OPTIONS = ["--thresholdForJITAfterWarmUp=10", "--thresholdForJITSoon=10", "--thresholdForOptimizeAfterWarmUp=20", "--thresholdForOptimizeAfterLongWarmUp=20", "--thresholdForOptimizeSoon=20", "--thresholdForFTLOptimizeAfterWarmUp=20", "--thresholdForFTLOptimizeSoon=20", "--maximumEvalCacheableSourceLength=150000"] 432 NO_CJIT_OPTIONS = ["--useConcurrentJIT=false", "--thresholdForJITAfterWarmUp=100" ]432 NO_CJIT_OPTIONS = ["--useConcurrentJIT=false", "--thresholdForJITAfterWarmUp=100", "--thresholdForJITSoon=100", "--thresholdForOptimizeAfterWarmUp=1000", "--thresholdForOptimizeAfterLongWarmUp=1000", "--thresholdForOptimizeSoon=1000", "--executionCounterIncrementForLoop=1", "--executionCounterIncrementForEntry=15", "--thresholdForFTLOptimizeAfterWarmUp=100000", "--thresholdForFTLOptimizeSoon=1000", "--ftlTierUpCounterIncrementForLoop=1", "--ftlTierUpCounterIncrementForReturn=15", "--evalThresholdMultiplier=10", "--optimizationThresholdScalingFactorA=0.061504", "--optimizationThresholdScalingFactorB=1.02406", "--optimizationThresholdScalingFactorC=0.0", "--optimizationThresholdScalingFactorD=0.825914"] 433 433 FTL_OPTIONS = ["--useFTLJIT=true"] 434 434
Note:
See TracChangeset
for help on using the changeset viewer.