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

Introduce object pooling #479

Merged
merged 6 commits into from Feb 11, 2018
Merged

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Feb 8, 2018

This PR introduces object pooling for top memory pressure creators:

  • Reference
  • Completion
  • ArgumentsInstance

With this change they practically disappear from performance report. The approach is opportunistic/best effort. When we are in code path that no longer needs the deep-acquire object we release it, unfortunately using pattern cannot be used.

Esprima.Benchmark.DromaeoBenchmark

Diff Method FileName Mean Gen 0 Gen 1 Gen 2 Allocated
Old Run dromaeo-3d-cube 107.09 ms 7437.5000 250.0000 - 31.67 MB
New 107.96 ms (+1%) 1312.5000 (-82%) 250.0000 (0%) - 7107.59 KB (-78%)
Old Run dromaeo-core-eval 25.92 ms 1718.7500 - - 6.9 MB
New 24.98 ms (-4%) 62.5000 (-96%) - - 298.95 KB (-96%)
Old Run dromaeo-object-array 270.44 ms 45125.0000 2062.5000 1000.0000 186.35 MB
New 262.77 ms (-3%) 39500.0000 (-12%) 2000.0000 (-3%) 1000.0000 (0%) 166027.07 KB (-11%)
Old Run dromaeo-object-regexp 1,168.48 ms 71812.5000 35312.5000 22250.0000 479.86 MB
New 1,141.61 ms (-2%) 57562.5000 (-20%) 35062.5000 (-1%) 22000.0000 (-1%) 434680.59 KB (-9%)
Old Run dromaeo-object-string 1,584.29 ms 249500.0000 183437.5000 179187.5000 1457.82 MB
New 1,524.09 ms (-4%) 226687.5000 (-9%) 184625.0000 (+1%) 181687.5000 (+1%) 1393645.01 KB (-4%)
Old Run dromaeo-string-base64 236.82 ms 16062.5000 375.0000 - 65.37 MB
New 236.61 ms (0%) 6187.5000 (-61%) 187.5000 (-50%) - 26458.12 KB (-60%)

Esprima.Benchmark.SunSpiderBenchmark

Diff Method FileName Mean Gen 0 Gen 1 Gen 2 Allocated
Old Run 3d-cube 848.7 ms 63687.5000 312.5000 62.5000 256.97 MB
New 826.2 ms (-3%) 10250.0000 (-84%) 312.5000 (0%) 62.5000 (0%) 42.9 MB (-83%)
Old Run 3d-morph 796.1 ms 41937.5000 5875.0000 1812.5000 193.86 MB
New 759.8 ms (-5%) 10875.0000 (-74%) 2312.5000 (-61%) 1000.0000 (-45%) 61.05 MB (-69%)
Old Run 3d-raytrace 648.6 ms 53562.5000 1000.0000 125.0000 216.57 MB
New 648.5 ms (0%) 21937.5000 (-59%) 500.0000 (-50%) 62.5000 (-50%) 90.1 MB (-58%)
Old Run access-binary-trees 260.5 ms 36125.0000 437.5000 - 145.24 MB
New 259.5 ms (0%) 19187.5000 (-47%) 250.0000 (-43%) - 77.08 MB (-47%)
Old Run access-fannkuch 2,707.8 ms 172437.5000 250.0000 - 689.76 MB
New 2,656.7 ms (-2%) 7062.5000 (-96%) 250.0000 (0%) - 28.43 MB (-96%)
Old Run access-nbody 764.4 ms 57500.0000 62.5000 - 230.06 MB
New 745.0 ms (-3%) 10625.0000 (-82%) 62.5000 (0%) - 42.73 MB (-81%)
Old Run access-nsieve 980.3 ms 62937.5000 7937.5000 2937.5000 260.87 MB
New 948.8 ms (-3%) 12812.5000 (-80%) 3875.0000 (-51%) 1812.5000 (-38%) 62.71 MB (-76%)
Old Run bitops-3bit-bits-in-byte 560.9 ms 54937.5000 - - 219.81 MB
New 544.9 ms (-3%) 20687.5000 (-62%) - - 82.99 MB (-62%)
Old Run bitops-bits-in-byte 965.9 ms 80625.0000 62.5000 - 322.7 MB
New 947.1 ms (-2%) 13437.5000 (-83%) 62.5000 (0%) - 53.98 MB (-83%)
Old Run bitops-bitwise-and 653.2 ms 45625.0000 62.5000 - 182.65 MB
New 600.7 ms (-8%) 10125.0000 (-78%) - - 40.74 MB (-78%)
Old Run bitops-nsieve-bits 1,047.0 ms 66750.0000 4375.0000 375.0000 269.04 MB
New 1,010.6 ms (-3%) 17250.0000 (-74%) 250.0000 (-94%) 62.5000 (-83%) 71.02 MB (-74%)
Old Run controlflow-recursive 357.1 ms 55687.5000 - - 222.91 MB
New 358.6 ms (0%) 29062.5000 (-48%) 62.5000 - 116.32 MB (-48%)
Old Run crypto-aes 643.3 ms 44250.0000 312.5000 62.5000 179.2 MB
New 645.4 ms (0%) 5250.0000 (-88%) 250.0000 (-20%) - 23.11 MB (-87%)
Old Run crypto-md5 421.5 ms 51250.0000 312.5000 62.5000 207.1 MB
New 409.2 ms (-3%) 30187.5000 (-41%) 312.5000 (0%) 62.5000 (0%) 123.04 MB (-41%)
Old Run crypto-sha1 417.5 ms 47687.5000 312.5000 62.5000 192.39 MB
New 404.7 ms (-3%) 24875.0000 (-48%) 187.5000 (-40%) - 101.27 MB (-47%)
Old Run date-format-tofte 433.6 ms 36062.5000 - - 144.36 MB
New 425.1 ms (-2%) 12187.5000 (-66%) 62.5000 - 49.05 MB (-66%)
Old Run date-format-xparb 373.4 ms 18062.5000 250.0000 - 72.86 MB
New 372.6 ms (0%) 10750.0000 (-40%) 250.0000 (0%) - 43.57 MB (-40%)
Old Run math-cordic 1,253.7 ms 110000.0000 125.0000 - 440.03 MB
New 1,220.4 ms (-3%) 21562.5000 (-80%) 62.5000 (-50%) - 86.4 MB (-80%)
Old Run math-partial-sums 401.5 ms 26812.5000 - - 107.29 MB
New 390.7 ms (-3%) 6500.0000 (-76%) - - 26.15 MB (-76%)
Old Run math-spectral-norm 475.1 ms 48312.5000 - - 193.43 MB
New 458.3 ms (-4%) 19187.5000 (-60%) - - 76.96 MB (-60%)
Old Run regexp-dna 343.3 ms 2000.0000 1687.5000 1375.0000 13.46 MB
New 343.7 ms (0%) 2250.0000 (+13%) 1937.5000 (+15%) 1562.5000 (+14%) 13.45 MB (0%)
Old Run string-base64 350.1 ms 23812.5000 250.0000 - 96.61 MB
New 351.1 ms (0%) 8812.5000 (-63%) 437.5000 (+75%) - 36.92 MB (-62%)
Old Run string-fasta 601.0 ms 57875.0000 - - 231.69 MB
New 596.6 ms (-1%) 25625.0000 (-56%) - - 102.6 MB (-56%)
Old Run string-tagcloud 257.0 ms 26187.5000 2125.0000 750.0000 113.18 MB
New 250.7 ms (-2%) 14875.0000 (-43%) 1687.5000 (-21%) 625.0000 (-17%) 68.05 MB (-40%)
Old Run string-unpack-code 202.0 ms 27187.5000 6250.0000 1375.0000 118.12 MB
New 197.2 ms (-2%) 14625.0000 (-46%) 4625.0000 (-26%) 1187.5000 (-14%) 70.22 MB (-41%)
Old Run string-validate-input 241.7 ms 20375.0000 375.0000 62.5000 84.8 MB
New 236.3 ms (-2%) 7500.0000 (-63%) 250.0000 (-33%) 62.5000 (0%) 35.24 MB (-58%)

Jint.Benchmark.ArrayBenchmark

Diff Method N Mean Gen 0 Allocated
Old Slice 100 672.9 us 149.4141 615.63 KB
New 685.5 us (+2%) 145.5078 (-3%) 598.44 KB (-3%)
Old Concat 100 827.7 us 166.0156 683.59 KB
New 791.7 us (-4%) 162.1094 (-2%) 666.41 KB (-3%)
Old Unshift 100 30,986.7 us 3687.5000 15212.5 KB
New 31,235.1 us (+1%) 3031.2500 (-18%) 12525.78 KB (-18%)
Old Push 100 17,942.8 us 1406.2500 5846.09 KB
New 18,001.2 us (0%) 593.7500 (-58%) 2518.75 KB (-57%)
Old Index 100 16,693.3 us 1250.0000 5171.09 KB
New 16,898.0 us (+1%) 343.7500 (-73%) 1515.63 KB (-71%)
Old Map 100 4,334.2 us 1437.5000 5903.13 KB
New 4,324.5 us (0%) 796.8750 (-45%) 3286.72 KB (-44%)
Old Apply 100 942.3 us 183.5938 752.34 KB
New 960.3 us (+2%) 176.7578 (-4%) 727.34 KB (-3%)
Old JsonStringifyParse 100 5,271.2 us 1250.0000 5140.63 KB
New 5,371.5 us (+2%) 1242.1875 (-1%) 5111.72 KB (-1%)

Jint.Benchmark.ArrayStressBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Jint 20 1.706 s 92437.5000 12562.5000 385.91 MB
New 1.643 s (-4%) 60000.0000 (-35%) 5000.0000 (-60%) 249.81 MB (-35%)

Jint.Benchmark.EvaluationBenchmark

Diff Method N Mean Gen 0 Allocated
Old Jint 20 765.5 us 134.7656 554.69 KB
New 743.9 us (-3%) 120.1172 (-11%) 495.16 KB (-11%)

Jint.Benchmark.LinqJsBenchmark

Diff Method N Mean Gen 0 Gen 1 Gen 2 Allocated
Old Jint 10 76.41 ms 5187.5000 2500.0000 187.5000 30.71 MB
New 71.07 ms (-7%) 5062.5000 (-2%) 2500.0000 (0%) - 30.47 MB (-1%)

Jint.Benchmark.MinimalScriptBenchmark

Diff Method N Mean Gen 0 Allocated
Old Jint 10 23.65 us 8.5144 34.92 KB
New 22.37 us (-5%) 8.2092 (-4%) 33.67 KB (-4%)

Jint.Benchmark.StopwatchBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Jint 1 1.598 s 118562.5000 125.0000 474.43 MB
New 1.535 s (-4%) 18875.0000 (-84%) 125.0000 (0%) 75.75 MB (-84%)

Jint.Benchmark.UncacheableExpressionsBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Benchmark 500 481.7 ms 94187.5000 250.0000 377.11 MB
New 475.6 ms (-1%) 52812.5000 (-44%) 62.5000 (-75%) 211.35 MB (-44%)

@sebastienros sebastienros merged commit 707244d into sebastienros:dev Feb 11, 2018
@lahma lahma deleted the perf/reference-pool branch February 11, 2018 20:36
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.

None yet

2 participants