Skip to main content
JS compilation
    hot or not?




                  Zbigniew Braniecki (gandalf@mozilla.com)
let’s talk about benchmarks
5 categories of benchmarks
5 categories of benchmarks
•   Real applications
5 categories of benchmarks
•   Real applications
•   Modified applications
    (eg. with I/O removed to make it CPU-bound)
5 categories of benchmarks
•   Real applications
•   Modified applications
    (eg. with I/O removed to make it CPU-bound)

•   Kernels
    (key fragments of real applications)
5 categories of benchmarks
•   Real applications
•   Modified applications
    (eg. with I/O removed to make it CPU-bound)

•   Kernels
    (key fragments of real applications)

•   Toy benchmarks
    (eg. sieve of Erastosthenes)
5 categories of benchmarks
•   Real applications
•   Modified applications
    (eg. with I/O removed to make it CPU-bound)

•   Kernels
    (key fragments of real applications)

•   Toy benchmarks
    (eg. sieve of Erastosthenes)

•   Synthetic benchmarks
    (code created artificially to fit a profile of particular operations, e.g Dhrystone)
statistics
statistics

•   How common is average?
statistics

•   How common is average?

•   Biases (sampling, memory etc.)
statistics

•   How common is average?

•   Biases (sampling, memory etc.)

•   Measuring the right thing is hard
statistics

•   How common is average?

•   Biases (sampling, memory etc.)

•   Measuring the right thing is hard

•   Reducing complexity
History


How did browser JS performance improve over time
V8
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
V8

5000


3750


2500


1250


   0
       1.0   1.5   2.0   3.0    3.5   3.6   4   Nightly-JS
SunSpider
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider

20000


15000


10000


 5000


    0
        1.0   1.5   2.0   3.0   3.5   3.6   4   Nightly-JS
SunSpider
SunSpider

3000


2250


1500


 750


   0
       3.0   3.5      3.6   4.0   Nightly-JS
SunSpider

3000


2250


1500


 750


   0
       3.0   3.5      3.6   4.0   Nightly-JS
SunSpider

3000


2250


1500


 750


   0
       3.0   3.5      3.6   4.0   Nightly-JS
SunSpider

3000


2250


1500


 750


   0
       3.0   3.5      3.6   4.0   Nightly-JS
SunSpider

3000


2250


1500


 750


   0
       3.0   3.5      3.6   4.0   Nightly-JS
SunSpider

3000


2250


1500


 750


   0
       3.0   3.5      3.6   4.0   Nightly-JS
Kraken
Kraken

50000


37500


25000


12500


    0
        3.0   3.5     3.6   4.0   Nightly-JS
Kraken

50000


37500


25000


12500


    0
        3.0   3.5     3.6   4.0   Nightly-JS
Kraken

50000


37500


25000


12500


    0
        3.0   3.5     3.6   4.0   Nightly-JS
Kraken

50000


37500


25000


12500


    0
        3.0   3.5     3.6   4.0   Nightly-JS
Kraken

50000


37500


25000


12500


    0
        3.0   3.5     3.6   4.0   Nightly-JS
Kraken

50000


37500


25000


12500


    0
        3.0   3.5     3.6   4.0   Nightly-JS
Types of JIT


method    vs.       tracing
method JIT
                 heap

     10
      9
      8
      7
      6
      5
      4
      3
      2
      1
      0
             a          b
method JIT
                 heap

     10
      9
      8
      7
      6
      5
      4
      3
      2
      1
      0
             a          b
method JIT
                 heap

     10
      9
      8
      7
      6
      5
      4
      3
      2
      1
      0
             a          b
method JIT
                 heap

     10
      9
      8
      7
      6
      5
      4
      3
      2
      1
      0
             a          b
method JIT
                 heap

     10
      9
      8
      7
      6
      5
      4
      3
      2
      1
      0
             a          b
method JIT
                 heap

     10
      9
      8
      7
      6
      5
      4
      3
      2
      1
      0
             a          b
method JIT
                     heap
hot loop!
            10
             9
             8
             7
             6
             5
             4
             3
             2
             1
             0
                 a          b
tracing JIT
              heap
  a
      10
       9
       8
       7
       6
       5
       4
       3
       2
       1
       0
                a
tracing JIT
                  heap
  b
      10
       9
       8
       7
       6
       5
       4
       3
       2
       1
       0
              a          b
tracing JIT
                      heap
         b
             10
              9
              8
              7
              6
              5
              4
              3
              2
              1
              0
hot trace!        a          b
How browsers compile stuff

•   Chakra (IE) - method

•   Carakan (Opera) - method

•   Nitro (Safari) - method

•   V8 (Chrome) - method

•   JägerMonkey (Firefox) - trace + method
method vs. tracing
How to help JIT
  hot loop!                b




                  hot trace!
What to avoid

•   competing heaps

•   variable type changing

•   evals

•   looong methods
Future

•   Dead code elimination

•   Type Interface

•   Function inlining

•   CrankShaft (Chrome) and IonMonkey (Firefox)
Questions?
Thank You!