<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[203318] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/203318">203318</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-15 19:12:31 -0700 (Fri, 15 Jul 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[JSC] Change some parameters based on a random search
https://bugs.webkit.org/show_bug.cgi?id=158514
Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-07-15
Reviewed by Saam Barati.
Source/JavaScriptCore:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::optimizationThresholdScalingFactor):
* runtime/Options.h:
Tools:
* Scripts/run-jsc-stress-tests:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeOptionsh">trunk/Source/JavaScriptCore/runtime/Options.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrunjscstresstests">trunk/Tools/Scripts/run-jsc-stress-tests</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (203317 => 203318)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-07-16 01:43:53 UTC (rev 203317)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-07-16 02:12:31 UTC (rev 203318)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-07-15 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Change some parameters based on a random search
+ https://bugs.webkit.org/show_bug.cgi?id=158514
+
+ Reviewed by Saam Barati.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::optimizationThresholdScalingFactor):
+ * runtime/Options.h:
+
</ins><span class="cx"> 2016-07-15 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Assertion failures and crashes with missing TDZ checks for catch-node bindings.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (203317 => 203318)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-07-16 01:43:53 UTC (rev 203317)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-07-16 02:12:31 UTC (rev 203318)
</span><span class="lines">@@ -3693,68 +3693,16 @@
</span><span class="cx">
</span><span class="cx"> double CodeBlock::optimizationThresholdScalingFactor()
</span><span class="cx"> {
</span><del>- // This expression arises from doing a least-squares fit of
- //
- // F[x_] =: a * Sqrt[x + b] + Abs[c * x] + d
- //
- // against the data points:
- //
- // x F[x_]
- // 10 0.9 (smallest reasonable code block)
- // 200 1.0 (typical small-ish code block)
- // 320 1.2 (something I saw in 3d-cube that I wanted to optimize)
- // 1268 5.0 (something I saw in 3d-cube that I didn't want to optimize)
- // 4000 5.5 (random large size, used to cause the function to converge to a shallow curve of some sort)
- // 10000 6.0 (similar to above)
- //
- // I achieve the minimization using the following Mathematica code:
- //
- // MyFunctionTemplate[x_, a_, b_, c_, d_] := a*Sqrt[x + b] + Abs[c*x] + d
- //
- // samples = {{10, 0.9}, {200, 1}, {320, 1.2}, {1268, 5}, {4000, 5.5}, {10000, 6}}
- //
- // solution =
- // Minimize[Plus @@ ((MyFunctionTemplate[#[[1]], a, b, c, d] - #[[2]])^2 & /@ samples),
- // {a, b, c, d}][[2]]
- //
- // And the code below (to initialize a, b, c, d) is generated by:
- //
- // Print["const double " <> ToString[#[[1]]] <> " = " <>
- // If[#[[2]] < 0.00001, "0.0", ToString[#[[2]]]] <> ";"] & /@ solution
- //
- // We've long known the following to be true:
- // - Small code blocks are cheap to optimize and so we should do it sooner rather
- // than later.
- // - Large code blocks are expensive to optimize and so we should postpone doing so,
- // and sometimes have a large enough threshold that we never optimize them.
- // - The difference in cost is not totally linear because (a) just invoking the
- // DFG incurs some base cost and (b) for large code blocks there is enough slop
- // in the correlation between instruction count and the actual compilation cost
- // that for those large blocks, the instruction count should not have a strong
- // influence on our threshold.
- //
- // I knew the goals but I didn't know how to achieve them; so I picked an interesting
- // example where the heuristics were right (code block in 3d-cube with instruction
- // count 320, which got compiled early as it should have been) and one where they were
- // totally wrong (code block in 3d-cube with instruction count 1268, which was expensive
- // to compile and didn't run often enough to warrant compilation in my opinion), and
- // then threw in additional data points that represented my own guess of what our
- // heuristics should do for some round-numbered examples.
- //
- // The expression to which I decided to fit the data arose because I started with an
- // affine function, and then did two things: put the linear part in an Abs to ensure
- // that the fit didn't end up choosing a negative value of c (which would result in
- // the function turning over and going negative for large x) and I threw in a Sqrt
- // term because Sqrt represents my intution that the function should be more sensitive
- // to small changes in small values of x, but less sensitive when x gets large.
-
- // Note that the current fit essentially eliminates the linear portion of the
- // expression (c == 0.0).
- const double a = 0.061504;
- const double b = 1.02406;
- const double c = 0.0;
- const double d = 0.825914;
-
</del><ins>+ // We want a good threshold based on the instruction count.
+ // Here, we are trying to optimize the following formula:
+ // F[x_] =: a * Sqrt[x + b] + Abs[c * x] + d
+ // The parameters were chosen by testing random values
+ // between 1 and 2 and keeping the best combination.
+ const double a = Options::optimizationThresholdScalingFactorA();
+ const double b = Options::optimizationThresholdScalingFactorB();
+ const double c = Options::optimizationThresholdScalingFactorC();
+ const double d = Options::optimizationThresholdScalingFactorD();
+
</ins><span class="cx"> double instructionCount = this->instructionCount();
</span><span class="cx">
</span><span class="cx"> ASSERT(instructionCount); // Make sure this is called only after we have an instruction stream; otherwise it'll just return the value of d, which makes no sense.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Options.h (203317 => 203318)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Options.h        2016-07-16 01:43:53 UTC (rev 203317)
+++ trunk/Source/JavaScriptCore/runtime/Options.h        2016-07-16 02:12:31 UTC (rev 203318)
</span><span class="lines">@@ -98,6 +98,44 @@
</span><span class="cx"> unsigned m_highLimit;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+#if CPU(X86_64)
+constexpr int32_t archThresholdForJITAfterWarmUp = 610;
+constexpr int32_t archThresholdForJITSoon = 89;
+constexpr int32_t archThresholdForOptimizeAfterWarmUp = 864;
+constexpr int32_t archThresholdForOptimizeAfterLongWarmUp = 1489;
+constexpr int32_t archThresholdForOptimizeSoon = 864;
+constexpr int32_t archExecutionCounterIncrementForLoop = 2;
+constexpr int32_t archExecutionCounterIncrementForEntry = 16;
+constexpr int32_t archThresholdForFTLOptimizeAfterWarmUp = 109160;
+constexpr int32_t archThresholdForFTLOptimizeSoon = 825;
+constexpr int32_t archFtlTierUpCounterIncrementForLoop = 8;
+constexpr int32_t archFtlTierUpCounterIncrementForReturn = 27;
+constexpr unsigned archFtlOSREntryRetryThreshold = 109;
+constexpr double archOptimizationThresholdScalingFactorA = 0.0258587392234135;
+constexpr double archOptimizationThresholdScalingFactorB = 1.2428014544978696;
+constexpr double archOptimizationThresholdScalingFactorC = 0.0013276440240339;
+constexpr double archOptimizationThresholdScalingFactorD = 1.3130654609331458;
+constexpr int32_t archEvalThresholdMultiplier = 12;
+#else
+constexpr int32_t archThresholdForJITAfterWarmUp = 500;
+constexpr int32_t archThresholdForJITSoon = 100;
+constexpr int32_t archThresholdForOptimizeAfterWarmUp = 1000;
+constexpr int32_t archThresholdForOptimizeAfterLongWarmUp = 1000;
+constexpr int32_t archThresholdForOptimizeSoon = 1000;
+constexpr int32_t archExecutionCounterIncrementForLoop = 1;
+constexpr int32_t archExecutionCounterIncrementForEntry = 15;
+constexpr int32_t archThresholdForFTLOptimizeAfterWarmUp = 100000;
+constexpr int32_t archThresholdForFTLOptimizeSoon = 1000;
+constexpr int32_t archFtlTierUpCounterIncrementForLoop = 1;
+constexpr int32_t archFtlTierUpCounterIncrementForReturn = 15;
+constexpr unsigned archFtlOSREntryRetryThreshold = 100;
+constexpr double archOptimizationThresholdScalingFactorA = 0.061504;
+constexpr double archOptimizationThresholdScalingFactorB = 1.02406;
+constexpr double archOptimizationThresholdScalingFactorC = 0.0;
+constexpr double archOptimizationThresholdScalingFactorD = 0.825914;
+constexpr int32_t archEvalThresholdMultiplier = 10;
+#endif
+
</ins><span class="cx"> typedef OptionRange optionRange;
</span><span class="cx"> typedef const char* optionString;
</span><span class="cx">
</span><span class="lines">@@ -253,23 +291,28 @@
</span><span class="cx"> \
</span><span class="cx"> v(double, jitPolicyScale, 1.0, Normal, "scale JIT thresholds to this specified ratio between 0.0 (compile ASAP) and 1.0 (compile like normal).") \
</span><span class="cx"> v(bool, forceEagerCompilation, false, Normal, nullptr) \
</span><del>- v(int32, thresholdForJITAfterWarmUp, 500, Normal, nullptr) \
- v(int32, thresholdForJITSoon, 100, Normal, nullptr) \
</del><ins>+ v(int32, thresholdForJITAfterWarmUp, archThresholdForJITAfterWarmUp, Normal, nullptr) \
+ v(int32, thresholdForJITSoon, archThresholdForJITSoon, Normal, nullptr) \
</ins><span class="cx"> \
</span><del>- v(int32, thresholdForOptimizeAfterWarmUp, 1000, Normal, nullptr) \
- v(int32, thresholdForOptimizeAfterLongWarmUp, 1000, Normal, nullptr) \
- v(int32, thresholdForOptimizeSoon, 1000, Normal, nullptr) \
- v(int32, executionCounterIncrementForLoop, 1, Normal, nullptr) \
- v(int32, executionCounterIncrementForEntry, 15, Normal, nullptr) \
</del><ins>+ v(int32, thresholdForOptimizeAfterWarmUp, archThresholdForOptimizeAfterWarmUp, Normal, nullptr) \
+ v(int32, thresholdForOptimizeAfterLongWarmUp, archThresholdForOptimizeAfterLongWarmUp, Normal, nullptr) \
+ v(int32, thresholdForOptimizeSoon, archThresholdForOptimizeSoon, Normal, nullptr) \
+ v(int32, executionCounterIncrementForLoop, archExecutionCounterIncrementForLoop, Normal, nullptr) \
+ v(int32, executionCounterIncrementForEntry, archExecutionCounterIncrementForEntry, Normal, nullptr) \
</ins><span class="cx"> \
</span><del>- v(int32, thresholdForFTLOptimizeAfterWarmUp, 100000, Normal, nullptr) \
- v(int32, thresholdForFTLOptimizeSoon, 1000, Normal, nullptr) \
- v(int32, ftlTierUpCounterIncrementForLoop, 1, Normal, nullptr) \
- v(int32, ftlTierUpCounterIncrementForReturn, 15, Normal, nullptr) \
</del><ins>+ v(int32, thresholdForFTLOptimizeAfterWarmUp, archThresholdForFTLOptimizeAfterWarmUp, Normal, nullptr) \
+ v(int32, thresholdForFTLOptimizeSoon, archThresholdForFTLOptimizeSoon, Normal, nullptr) \
+ v(int32, ftlTierUpCounterIncrementForLoop, archFtlTierUpCounterIncrementForLoop, Normal, nullptr) \
+ v(int32, ftlTierUpCounterIncrementForReturn, archFtlTierUpCounterIncrementForReturn, Normal, nullptr) \
</ins><span class="cx"> v(unsigned, ftlOSREntryFailureCountForReoptimization, 15, Normal, nullptr) \
</span><del>- v(unsigned, ftlOSREntryRetryThreshold, 100, Normal, nullptr) \
</del><ins>+ v(unsigned, ftlOSREntryRetryThreshold, archFtlOSREntryRetryThreshold, Normal, nullptr) \
</ins><span class="cx"> \
</span><del>- v(int32, evalThresholdMultiplier, 10, Normal, nullptr) \
</del><ins>+ v(double, optimizationThresholdScalingFactorA, archOptimizationThresholdScalingFactorA, Normal, nullptr) \
+ v(double, optimizationThresholdScalingFactorB, archOptimizationThresholdScalingFactorB, Normal, nullptr) \
+ v(double, optimizationThresholdScalingFactorC, archOptimizationThresholdScalingFactorC, Normal, nullptr) \
+ v(double, optimizationThresholdScalingFactorD, archOptimizationThresholdScalingFactorD, Normal, nullptr) \
+ \
+ v(int32, evalThresholdMultiplier, archEvalThresholdMultiplier, Normal, nullptr) \
</ins><span class="cx"> v(unsigned, maximumEvalCacheableSourceLength, 256, Normal, nullptr) \
</span><span class="cx"> \
</span><span class="cx"> v(bool, randomizeExecutionCountsBetweenCheckpoints, false, Normal, nullptr) \
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (203317 => 203318)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-07-16 01:43:53 UTC (rev 203317)
+++ trunk/Tools/ChangeLog        2016-07-16 02:12:31 UTC (rev 203318)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-07-15 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Change some parameters based on a random search
+ https://bugs.webkit.org/show_bug.cgi?id=158514
+
+ Reviewed by Saam Barati.
+
+ * Scripts/run-jsc-stress-tests:
+
</ins><span class="cx"> 2016-07-15 Jon Davis <jond@apple.com>
</span><span class="cx">
</span><span class="cx"> Changed the start page URL for WebKit Nightly builds.
</span></span></pre></div>
<a id="trunkToolsScriptsrunjscstresstests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-jsc-stress-tests (203317 => 203318)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-jsc-stress-tests        2016-07-16 01:43:53 UTC (rev 203317)
+++ trunk/Tools/Scripts/run-jsc-stress-tests        2016-07-16 02:12:31 UTC (rev 203318)
</span><span class="lines">@@ -429,7 +429,7 @@
</span><span class="cx"> # We force all tests to use a smaller (1.5M) stack so that stack overflow tests can run faster.
</span><span class="cx"> BASE_OPTIONS = ["--useFTLJIT=false", "--useFunctionDotArguments=true", "--maxPerThreadStackUsage=1572864"]
</span><span class="cx"> EAGER_OPTIONS = ["--thresholdForJITAfterWarmUp=10", "--thresholdForJITSoon=10", "--thresholdForOptimizeAfterWarmUp=20", "--thresholdForOptimizeAfterLongWarmUp=20", "--thresholdForOptimizeSoon=20", "--thresholdForFTLOptimizeAfterWarmUp=20", "--thresholdForFTLOptimizeSoon=20", "--maximumEvalCacheableSourceLength=150000"]
</span><del>-NO_CJIT_OPTIONS = ["--useConcurrentJIT=false", "--thresholdForJITAfterWarmUp=100"]
</del><ins>+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"]
</ins><span class="cx"> FTL_OPTIONS = ["--useFTLJIT=true"]
</span><span class="cx">
</span><span class="cx"> $runlist = []
</span></span></pre>
</div>
</div>
</body>
</html>