Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize declarative environment record handling for functions #517

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Jun 22, 2018

All kinds of optimizations.

  • inline when JIT doesn't do it
  • ObjectInstance direct backing field of Dictionary works better, DeclarativeExecutionContext still benefits from MPC2
  • Mostly used net471 target to detect bad inlining, but probably benefits .NET Core and Full Framework better

ArrayBenchmark

Diff Method N Mean Gen 0 Allocated
Old Slice 100 444.1 us 161.1328 660.16 KB
New 419.5 us (-6%) 161.1328 (0%) 660.16 KB (0%)
Old Concat 100 478.3 us 175.7813 720.31 KB
New 474.5 us (-1%) 175.7813 (0%) 720.31 KB (0%)
Old Unshift 100 17,875.9 us 3562.5000 14672.66 KB
New 18,321.2 us (+2%) 3562.5000 (0%) 14672.66 KB (0%)
Old Push 100 10,700.9 us 343.7500 1438.28 KB
New 10,259.9 us (-4%) 343.7500 (0%) 1438.28 KB (0%)
Old Index 100 11,988.4 us 390.6250 1637.5 KB
New 11,690.5 us (-2%) 390.6250 (0%) 1637.5 KB (0%)
Old Map 100 3,191.3 us 691.4063 2833.59 KB
New 2,868.3 us (-10%) 687.5000 (-1%) 2830.47 KB (0%)
Old Apply 100 577.0 us 188.4766 774.22 KB
New 582.4 us (+1%) 188.4766 (0%) 774.22 KB (0%)
Old JsonStringifyParse 100 4,517.9 us 1273.4375 5225.78 KB
New 4,612.0 us (+2%) 1273.4375 (0%) 5242.19 KB (0%)
Old FilterWithString 100 36,423.1 us 5687.5000 23338.28 KB
New 32,967.5 us (-9%) 5687.5000 (0%) 23335.16 KB (0%)

ArrayStressBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Jint 20 592.4 ms 60000.0000 2937.5000 245.9 MB
New 560.9 ms (-5%) 59937.5000 (0%) 2937.5000 (0%) 245.9 MB (0%)

DromaeoBenchmark

Diff Method FileName Mean Gen 0 Gen 1 Gen 2 Allocated
Old Run dromaeo-3d-cube 74.51 ms 1375.0000 250.0000 - 7662.21 KB
New 73.62 ms (-1%) 1375.0000 (0%) 312.5000 (+25%) - 7722.41 KB (+1%)
Old Run dromaeo-core-eval 15.75 ms 62.5000 - - 298.7 KB
New 15.54 ms (-1%) 62.5000 (0%) - - 298.71 KB (0%)
Old Run dromaeo-object-array 157.05 ms 42437.5000 1937.5000 937.5000 178313.12 KB
New 159.04 ms (+1%) 42437.5000 (0%) 1937.5000 (0%) 937.5000 (0%) 178313.61 KB (0%)
Old Run dromaeo-object-regexp 891.11 ms 53625.0000 32312.5000 21687.5000 414359.71 KB
New 882.77 ms (-1%) 53750.0000 (0%) 31625.0000 (-2%) 22000.0000 (+1%) 417256.65 KB (+1%)
Old Run dromaeo-object-string 1,198.01 ms 218062.5000 174812.5000 172375.0000 1392917.21 KB
New 1,182.09 ms (-1%) 218687.5000 (0%) 175250.0000 (0%) 172875.0000 (0%) 1393573.49 KB (0%)
Old Run dromaeo-string-base64 169.39 ms 6375.0000 312.5000 - 27381.53 KB
New 167.69 ms (-1%) 6375.0000 (0%) 312.5000 (0%) - 27381.61 KB (0%)

EvaluationBenchmark

Diff Method N Mean Gen 0 Allocated
Old Jint 20 670.4 us 119.1406 488.91 KB
New 658.5 us (-2%) 118.1641 (-1%) 487.34 KB (0%)

LinqJsBenchmark

Diff Method N Mean Gen 0 Gen 1 Gen 2 Allocated
Old Jint 10 71.95 ms 5125.0000 2500.0000 125.0000 30.57 MB
New 69.62 ms (-3%) 5062.5000 (-1%) 2500.0000 (0%) - 30.52 MB (0%)

MinimalScriptBenchmark

Diff Method N Mean Gen 0 Allocated
Old Jint 10 18.42 us 8.1482 33.44 KB
New 20.47 us (+11%) 8.1482 (0%) 33.44 KB (0%)

StopwatchBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Jint 1 1.141 s 14375.0000 62.5000 57.73 MB
New 1.112 s (-3%) 18000.0000 (+25%) 62.5000 (0%) 72.22 MB (+25%)

SunSpiderBenchmark

Diff Method FileName Mean Gen 0 Gen 1 Gen 2 Allocated
Old Run 3d-cube 602.3 ms 11875.0000 312.5000 - 49.56 MB
New 588.8 ms (-2%) 11875.0000 (0%) 312.5000 (0%) - 49.56 MB (0%)
Old Run 3d-morph 565.8 ms 11812.5000 2500.0000 1062.5000 68.03 MB
New 565.3 ms (0%) 11812.5000 (0%) 2500.0000 (0%) 1062.5000 (0%) 68.03 MB (0%)
Old Run 3d-raytrace 486.8 ms 21875.0000 750.0000 125.0000 89.75 MB
New 465.5 ms (-4%) 21875.0000 (0%) 750.0000 (0%) 62.5000 (-50%) 89.75 MB (0%)
Old Run access-binary-trees 203.4 ms 16500.0000 437.5000 62.5000 68.51 MB
New 192.0 ms (-6%) 16625.0000 (+1%) 250.0000 (-43%) - 68.51 MB (0%)
Old Run access-fannkuch 1,872.9 ms 9437.5000 125.0000 - 37.87 MB
New 1,840.8 ms (-2%) 9437.5000 (0%) 125.0000 (0%) - 37.87 MB (0%)
Old Run access-nbody 563.8 ms 13062.5000 - - 52.42 MB
New 551.6 ms (-2%) 13062.5000 (0%) - - 52.42 MB (0%)
Old Run access-nsieve 716.9 ms 15375.0000 3937.5000 1875.0000 73.09 MB
New 694.4 ms (-3%) 15375.0000 (0%) 3937.5000 (0%) 1875.0000 (0%) 73.09 MB (0%)
Old Run bitops-3bit-bits-in-byte 404.7 ms 17562.5000 - - 70.27 MB
New 386.4 ms (-5%) 17562.5000 (0%) - - 70.27 MB (0%)
Old Run bitops-bits-in-byte 663.6 ms 11562.5000 62.5000 - 46.44 MB
New 647.6 ms (-2%) 11562.5000 (0%) 62.5000 (0%) - 46.44 MB (0%)
Old Run bitops-bitwise-and 427.2 ms 9000.0000 - - 36.01 MB
New 474.0 ms (+11%) 9000.0000 (0%) - - 36.01 MB (0%)
Old Run bitops-nsieve-bits 697.3 ms 21625.0000 125.0000 - 88.5 MB
New 688.6 ms (-1%) 21625.0000 (0%) 125.0000 (0%) - 88.5 MB (0%)
Old Run controlflow-recursive 292.0 ms 23625.0000 - - 94.61 MB
New 266.0 ms (-9%) 23625.0000 (0%) - - 94.61 MB (0%)
Old Run crypto-aes 435.4 ms 5500.0000 250.0000 - 24.14 MB
New 431.0 ms (-1%) 5500.0000 (0%) 312.5000 (+25%) - 24.12 MB (0%)
Old Run crypto-md5 322.3 ms 28000.0000 250.0000 62.5000 114.57 MB
New 302.8 ms (-6%) 28000.0000 (0%) 250.0000 (0%) 62.5000 (0%) 114.57 MB (0%)
Old Run crypto-sha1 306.3 ms 22687.5000 312.5000 62.5000 92.28 MB
New 296.1 ms (-3%) 22687.5000 (0%) 312.5000 (0%) 62.5000 (0%) 92.28 MB (0%)
Old Run date-format-tofte 325.1 ms 11875.0000 - - 47.71 MB
New 319.6 ms (-2%) 11687.5000 (-2%) 62.5000 - 47.06 MB (-1%)
Old Run date-format-xparb 328.9 ms 10000.0000 250.0000 - 40.85 MB
New 321.7 ms (-2%) 10125.0000 (+1%) 250.0000 (0%) - 41.22 MB (+1%)
Old Run math-cordic 914.1 ms 20562.5000 62.5000 - 82.43 MB
New 908.0 ms (-1%) 20562.5000 (0%) 62.5000 (0%) - 82.43 MB (0%)
Old Run math-partial-sums 293.1 ms 7000.0000 - - 28.07 MB
New 280.1 ms (-4%) 7000.0000 (0%) - - 28.07 MB (0%)
Old Run math-spectral-norm 348.2 ms 16875.0000 - - 67.63 MB
New 328.3 ms (-6%) 16875.0000 (0%) - - 67.63 MB (0%)
Old Run regexp-dna 342.7 ms 2187.5000 1875.0000 1500.0000 13.55 MB
New 344.0 ms (0%) 2312.5000 (+6%) 1875.0000 (0%) 1562.5000 (+4%) 13.54 MB (0%)
Old Run string-base64 256.9 ms 9312.5000 375.0000 - 38.79 MB
New 249.9 ms (-3%) 9312.5000 (0%) 375.0000 (0%) - 38.79 MB (0%)
Old Run string-fasta 432.6 ms 26750.0000 - - 107.01 MB
New 401.4 ms (-7%) 26000.0000 (-3%) 62.5000 - 104.02 MB (-3%)
Old Run string-tagcloud 205.8 ms 14000.0000 1687.5000 625.0000 64.92 MB
New 201.1 ms (-2%) 14125.0000 (+1%) 2062.5000 (+22%) 750.0000 (+20%) 64.54 MB (-1%)
Old Run string-unpack-code 157.0 ms 13750.0000 4750.0000 875.0000 64.88 MB
New 151.1 ms (-4%) 13750.0000 (0%) 4500.0000 (-5%) 1000.0000 (+14%) 64.88 MB (0%)
Old Run string-validate-input 176.1 ms 7312.5000 375.0000 62.5000 33.53 MB
New 171.0 ms (-3%) 7250.0000 (-1%) 437.5000 (+17%) 62.5000 (0%) 33.26 MB (-1%)

UncacheableExpressionsBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Benchmark 500 336.2 ms 48625.0000 11250.0000 196.66 MB
New 312.8 ms (-7%) 46750.0000 (-4%) 250.0000 (-98%) 187.34 MB (-5%)

@lahma lahma force-pushed the perf/optimize-declarative-environment-record branch from d95f66f to 29c18fc Compare June 22, 2018 20:08
… functions

* use explicit type field checks as small methods won't inline to small methods
* seal some classes
@lahma lahma force-pushed the perf/optimize-declarative-environment-record branch from 29c18fc to 3a1d137 Compare June 23, 2018 14:02
@lahma lahma force-pushed the perf/optimize-declarative-environment-record branch from 3a1d137 to 8def7f8 Compare June 23, 2018 16:15
@sebastienros sebastienros merged commit b5c4b57 into sebastienros:dev Jun 26, 2018
@lahma lahma deleted the perf/optimize-declarative-environment-record branch June 26, 2018 07:13
maximburyak pushed a commit to maximburyak/jint that referenced this pull request Jul 11, 2018
…tienros#517)

* sebastienros#451 optimize declarative environment record handling for functions

* use explicit type field checks as small methods won't inline to small methods
* seal some classes

* sebastienros#451 inline more hot paths

* sebastienros#451 use == instead of Equals for doubles as strings, less IL code

* sebastienros#451 minimize work done in hot paths

* sebastienros#451 use Dictionary directly in ObjectInstance as it caters better performance

* sebastienros#451 tweak property setting via direct field

* sebastienros#451 more tweaks

* sebastienros#451 use ArrayPrototype.ConstructFast when possible

* sebastienros#451 improve bounds check performance for .NET Core 2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants