Bug 69201 - All of JSC's heuristics should be in one place for easier tuning
Summary: All of JSC's heuristics should be in one place for easier tuning
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 69208
  Show dependency treegraph
 
Reported: 2011-09-30 18:17 PDT by Filip Pizlo
Modified: 2011-10-01 15:04 PDT (History)
5 users (show)

See Also:


Attachments
the patch (25.88 KB, patch)
2011-09-30 21:09 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (25.88 KB, patch)
2011-09-30 21:15 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch - attempt to fix windows (25.90 KB, patch)
2011-09-30 23:11 PDT, Filip Pizlo
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2011-09-30 18:17:58 PDT
Currenty JavaScriptCore has a large number of heuristic settings, such as optimization thresholds, recompilation thresholds, optimization delay thresholds, etc.  There are also a lot of old heuristics from even before tiered compilation, such as the maximum size of polymorphic access lists and the thrash thresholds for creating dictionaries and despecifying functions.

It would be great to have these thresholds in one file (or at least a handful of files), so that it is easier to reason about their relationships.

Settings that do not have to be in a header (because they are not accessed frequently and because they don't determine the layout of classes) should be in a .cpp file, so that they can be changed without recompiling all of WebKit.

Other settings should be in the corresponding header (of the same name), to make it easier to find them.
Comment 1 Filip Pizlo 2011-09-30 20:52:12 PDT
I hacked up a patch that does this, and also has an option where all of the heuristics can be controlled using environment variables.  This allowed me to tweak around with the various settings.  Here's what I find when I increase the threshold for when optimization kicks in by a factor of 10.  V8 wins, Kraken loses.

This is really worth investigating further.  Maybe there's a sweet spot!



Benchmark report for SunSpider, V8, and Kraken.

VMs tested:
"TipOfTree" at /Volumes/Data/pizlo/quinary/OpenSource/WebKitBuild/Release/jsc
"Heuristics" at /Volumes/Data/pizlo/senary/OpenSource/WebKitBuild/Release/jsc

Collected 12 samples per benchmark/VM, with 4 VM invocations per benchmark. Used 1 benchmark iteration per VM
invocation for warm-up. Used the jsc-specific preciseTime() function to get microsecond-level timing. Reporting
benchmark execution times with 95% confidence intervals in milliseconds.

                                            TipOfTree               Heuristics                                   
SunSpider:
   3d-cube                                7.6906+-0.2068    ?     7.7596+-0.2620       ?
   3d-morph                               7.4465+-0.1283    ?     7.6581+-0.1881       ? might be 1.0284x slower
   3d-raytrace                            8.2471+-0.1919    !     8.8701+-0.2425       ! definitely 1.0755x slower
   access-binary-trees                    1.8606+-0.1037    ?     1.9590+-0.0674       ? might be 1.0529x slower
   access-fannkuch                        6.6788+-0.2146          6.5927+-0.2252         might be 1.0131x faster
   access-nbody                           3.6278+-0.1156    ?     3.6838+-0.0670       ? might be 1.0154x slower
   access-nsieve                          2.6637+-0.0730    ?     2.6795+-0.0705       ?
   bitops-3bit-bits-in-byte               1.7849+-0.0586          1.7360+-0.0279         might be 1.0282x faster
   bitops-bits-in-byte                    2.7555+-0.0986    !     2.9485+-0.0850       ! definitely 1.0700x slower
   bitops-bitwise-and                     3.3116+-0.1161          3.3052+-0.0942       
   bitops-nsieve-bits                     5.6408+-0.2029          5.6077+-0.1539       
   controlflow-recursive                  2.0679+-0.0469    ?     2.1149+-0.0707       ? might be 1.0227x slower
   crypto-aes                             6.8625+-0.1968    ?     6.9410+-0.4183       ? might be 1.0114x slower
   crypto-md5                             2.8206+-0.0594    ?     2.9170+-0.1876       ? might be 1.0342x slower
   crypto-sha1                            2.5579+-0.0761    ?     2.5948+-0.0808       ? might be 1.0144x slower
   date-format-tofte                     10.1196+-0.3292         10.0692+-0.2650       
   date-format-xparb                      9.6261+-0.2888          9.2702+-0.2785         might be 1.0384x faster
   math-cordic                            6.4324+-0.1322    ?     6.5345+-0.2709       ? might be 1.0159x slower
   math-partial-sums                      7.5616+-0.1605    ?     7.7972+-0.1407       ? might be 1.0312x slower
   math-spectral-norm                     2.8596+-0.1089    ?     2.9433+-0.0722       ? might be 1.0293x slower
   regexp-dna                            10.8983+-0.1859    ?    11.0576+-0.1395       ? might be 1.0146x slower
   string-base64                          6.2564+-0.1731    ^     5.8365+-0.1670       ^ definitely 1.0719x faster
   string-fasta                           7.1414+-0.1872          7.1134+-0.2382       
   string-tagcloud                       12.0129+-0.3267    ?    12.2721+-0.3626       ? might be 1.0216x slower
   string-unpack-code                    21.6528+-0.6228         20.6743+-0.6671         might be 1.0473x faster
   string-validate-input                  6.6130+-0.2425    ?     6.6702+-0.2608       ?

   <arithmetic>                           6.4304+-0.0354    ?     6.4464+-0.0526       ?
   <geometric>                            5.2719+-0.0380    ?     5.3201+-0.0479       ?
   <harmonic>                             4.3149+-0.0548    ?     4.3748+-0.0496       ? might be 1.0139x slower

                                            TipOfTree               Heuristics                                   
V8:
   crypto                                73.9378+-1.7200    ^    70.7935+-1.1125       ^ definitely 1.0444x faster
   deltablue                            230.0161+-2.7634        226.3826+-1.2727         might be 1.0161x faster
   earley-boyer                          90.7387+-0.6798    ?    91.2552+-1.1652       ?
   raytrace                              62.5021+-0.8299         62.0781+-0.8338       
   regexp                               106.5030+-1.7636        104.6961+-0.8644         might be 1.0173x faster
   richards                             188.3154+-3.3034        184.6544+-2.0805         might be 1.0198x faster
   splay                                 92.9402+-1.3416         91.8982+-0.4769         might be 1.0113x faster

   <arithmetic>                         120.7076+-0.6592    ^   118.8226+-0.6105       ^ definitely 1.0159x faster
   <geometric>                          108.7153+-0.5950    ^   107.0578+-0.6092       ^ definitely 1.0155x faster
   <harmonic>                            99.4516+-0.5867    ^    97.9377+-0.6318       ^ definitely 1.0155x faster

                                            TipOfTree               Heuristics                                   
Kraken:
   ai-astar                             502.3658+-6.5577    ^   490.1612+-2.0308       ^ definitely 1.0249x faster
   audio-beat-detection                 194.3967+-3.6043        191.6740+-1.0048         might be 1.0142x faster
   audio-dft                            291.1872+-7.7290        286.4926+-5.5645         might be 1.0164x faster
   audio-fft                            129.9101+-2.1400    ^   126.8271+-0.5652       ^ definitely 1.0243x faster
   audio-oscillator                     269.2837+-3.6560        262.5009+-4.4634         might be 1.0258x faster
   imaging-darkroom                     426.1247+-4.0255    ^   336.4879+-5.2957       ^ definitely 1.2664x faster
   imaging-desaturate                   229.4139+-2.4708    ?   233.5722+-3.9622       ? might be 1.0181x slower
   imaging-gaussian-blur                582.8458+-3.2455    ?   591.1324+-9.3164       ? might be 1.0142x slower
   json-parse-financial                  49.6399+-0.6668         49.4632+-0.8152       
   json-stringify-tinderbox              71.6597+-1.1835         69.6183+-0.9957         might be 1.0293x faster
   stanford-crypto-aes                  132.8525+-1.3210    ^   102.1307+-1.1175       ^ definitely 1.3008x faster
   stanford-crypto-ccm                  103.1368+-1.0499        101.8944+-0.7486         might be 1.0122x faster
   stanford-crypto-pbkdf2               195.4435+-4.3892    !   391.9521+-5.5801       ! definitely 2.0054x slower
   stanford-crypto-sha256-iterative      85.7275+-0.7357    ?    88.3767+-3.3986       ? might be 1.0309x slower

   <arithmetic>                         233.1420+-0.4635    !   237.3060+-0.9258       ! definitely 1.0179x slower
   <geometric>                          182.6890+-0.4309    !   184.1216+-0.3057       ! definitely 1.0078x slower
   <harmonic>                           142.0580+-0.3506    ^   140.6889+-0.3872       ^ definitely 1.0097x faster

                                            TipOfTree               Heuristics                                   
All benchmarks:
   <arithmetic>                          90.9815+-0.1490    !    91.9500+-0.2205       ! definitely 1.0106x slower
   <geometric>                           23.7879+-0.1042    ?    23.9089+-0.1269       ?
   <harmonic>                             7.5872+-0.0941    ?     7.6871+-0.0850       ? might be 1.0132x slower
Comment 2 Filip Pizlo 2011-09-30 21:09:22 PDT
Created attachment 109394 [details]
the patch

This is performance-neutral, as I haven't changed any heuristics in this patch.  I have used it to see that there is room to tweak the heuristics, but I don't know yet what the sweet spot is.  I'll leave that for another patch.
Comment 3 WebKit Review Bot 2011-09-30 21:11:58 PDT
Attachment 109394 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/CMakeLists.txt', u'S..." exit_code: 1

Source/JavaScriptCore/runtime/Heuristics.cpp:27:  You should add a blank line after implementation file's own header.  [build/include_order] [4]
Source/JavaScriptCore/runtime/Heuristics.cpp:30:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Filip Pizlo 2011-09-30 21:15:01 PDT
Created attachment 109395 [details]
the patch
Comment 5 Filip Pizlo 2011-09-30 23:11:41 PDT
Created attachment 109398 [details]
the patch - attempt to fix windows
Comment 6 Filip Pizlo 2011-10-01 15:04:57 PDT
Landed in r96463.