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 JsString, JsBoolean etc and support efficient string concatenation #463

Merged
merged 7 commits into from
Jan 10, 2018

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Jan 9, 2018

  • Now JsValue is abstract class and types deriving from it
  • ObjectInstance is now inheriting from JsValue
  • Efficient string concatenation is now possible
  • Tweaked some thread local to be object members for prototypes as it's faster and there's only one prototype per engine

Abstraction seem to have brought some setback in speed, but allocations generally lower. dromaeo strings and SunSpider strings are pretty nice numbers. I guess we can do another round in optimizing if there are places to improve after this is OK.

EDIT, I was able to return speed by using ReferenceEquals for Undefined and Null which doesn't incur performance penalty like == calling polymorfic Equals.

Esprima.Benchmark.DromaeoBenchmark

Diff Method FileName Mean Gen 0 Gen 1 Gen 2 Allocated
Old Run dromaeo-3d-cube 122.53 ms 8000.0000 250.0000 - 33.65 MB
New 110.74 ms (-10%) 7250.0000 (-9%) 250.0000 (0%) - 31.85 MB (-5%)
Old Run dromaeo-core-eval 33.87 ms 9750.0000 - - 39.46 MB
New 26.99 ms (-20%) 1500.0000 (-85%) - - 6.9 MB (-83%)
Old Run dromaeo-object-array 304.51 ms 46250.0000 2250.0000 1000.0000 192.42 MB
New 288.25 ms (-5%) 45250.0000 (-2%) 2250.0000 (0%) 1000.0000 (0%) 186.78 MB (-3%)
Old Run dromaeo-object-regexp 1,196.14 ms 80416.6667 34000.0000 23000.0000 523.58 MB
New 1,145.92 ms (-4%) 72166.6667 (-10%) 36916.6667 (+9%) 21750.0000 (-5%) 483.17 MB (-8%)
Old Run dromaeo-object-string 6,901.06 ms 2993583.3333 1682333.3333 1676916.6667 15234.83 MB
New 1,333.29 ms (-81%) 234833.3333 (-92%) 168666.6667 (-90%) 164000.0000 (-90%) 1460.59 MB (-90%)
Old Run dromaeo-string-base64 350.69 ms 195750.0000 250.0000 - 786.27 MB
New 256.61 ms (-27%) 16750.0000 (-91%) 250.0000 (0%) - 67.54 MB (-91%)

Esprima.Benchmark.SunSpiderBenchmark

Diff Method FileName Mean Gen 0 Gen 1 Gen 2 Allocated
Old Run 3d-cube 963.5 ms 68000.0000 250.0000 - 274.9 MB
New 868.9 ms (-10%) 63750.0000 (-6%) 250.0000 (0%) - 257.9 MB (-6%)
Old Run 3d-morph 952.7 ms 46500.0000 7000.0000 1500.0000 216.4 MB
New 888.8 ms (-7%) 41666.6667 (-10%) 5500.0000 (-21%) 1250.0000 (-17%) 193.86 MB (-10%)
Old Run 3d-raytrace 729.0 ms 62750.0000 750.0000 - 253.7 MB
New 684.4 ms (-6%) 54250.0000 (-14%) 750.0000 (0%) - 219.35 MB (-14%)
Old Run access-binary-trees 297.5 ms 40750.0000 750.0000 - 164.69 MB
New 290.4 ms (-2%) 37750.0000 (-7%) 500.0000 (-33%) - 151.98 MB (-8%)
Old Run access-fannkuch 2,982.1 ms 172250.0000 250.0000 - 689.78 MB
New 2,732.3 ms (-8%) 172250.0000 (0%) 250.0000 (0%) - 689.77 MB (0%)
Old Run access-nbody 870.2 ms 63250.0000 - - 253.38 MB
New 792.9 ms (-9%) 57500.0000 (-9%) - - 230.28 MB (-9%)
Old Run access-nsieve 1,095.6 ms 65333.3333 8500.0000 2333.3333 272.02 MB
New 1,003.1 ms (-8%) 62750.0000 (-4%) 7750.0000 (-9%) 2750.0000 (+18%) 260.87 MB (-4%)
Old Run bitops-3bit-bits-in-byte 633.5 ms 60750.0000 - - 243.21 MB
New 589.7 ms (-7%) 56250.0000 (-7%) - - 225.67 MB (-7%)
Old Run bitops-bits-in-byte 1,067.2 ms 84000.0000 - - 336.33 MB
New 984.4 ms (-8%) 81500.0000 (-3%) - - 326.8 MB (-3%)
Old Run bitops-bitwise-and 882.8 ms 52250.0000 - - 209.8 MB
New 809.8 ms (-8%) 45500.0000 (-13%) - - 182.65 MB (-13%)
Old Run bitops-nsieve-bits 1,193.3 ms 73750.0000 4250.0000 250.0000 297.75 MB
New 1,099.6 ms (-8%) 66750.0000 (-9%) 2750.0000 (-35%) 250.0000 (0%) 269.04 MB (-10%)
Old Run controlflow-recursive 424.8 ms 64000.0000 250.0000 - 256.62 MB
New 393.0 ms (-7%) 58500.0000 (-9%) - - 234.15 MB (-9%)
Old Run crypto-aes 717.2 ms 45000.0000 250.0000 - 182.35 MB
New 665.8 ms (-7%) 44500.0000 (-1%) 250.0000 (0%) - 180.09 MB (-1%)
Old Run crypto-md5 465.4 ms 59000.0000 250.0000 - 238.53 MB
New 451.5 ms (-3%) 52500.0000 (-11%) 250.0000 (0%) - 212.71 MB (-11%)
Old Run crypto-sha1 474.1 ms 54750.0000 250.0000 - 221.08 MB
New 444.5 ms (-6%) 49000.0000 (-11%) 250.0000 (0%) - 197.82 MB (-11%)
Old Run date-format-tofte 483.8 ms 39000.0000 - - 156.02 MB
New 451.0 ms (-7%) 37250.0000 (-4%) - - 149.63 MB (-4%)
Old Run date-format-xparb 389.2 ms 20000.0000 250.0000 - 80.83 MB
New 387.3 ms (0%) 18500.0000 (-8%) 250.0000 (0%) - 74.92 MB (-7%)
Old Run math-cordic 1,439.6 ms 119500.0000 - - 478.26 MB
New 1,333.9 ms (-7%) 111250.0000 (-7%) - - 445.76 MB (-7%)
Old Run math-partial-sums 490.1 ms 30250.0000 - - 121.78 MB
New 455.5 ms (-7%) 26750.0000 (-12%) - - 107.29 MB (-12%)
Old Run math-spectral-norm 549.0 ms 53750.0000 - - 215.88 MB
New 495.8 ms (-10%) 49750.0000 (-7%) - - 199.05 MB (-8%)
Old Run regexp-dna 339.0 ms 1500.0000 1250.0000 1000.0000 13.64 MB
New 339.2 ms (0%) 1500.0000 (0%) 1250.0000 (0%) 1000.0000 (0%) 13.47 MB (-1%)
Old Run string-base64 500.3 ms 265250.0000 250.0000 - 1064.32 MB
New 378.6 ms (-24%) 24500.0000 (-91%) 250.0000 (0%) - 99.86 MB (-91%)
Old Run string-fasta 709.1 ms 62750.0000 - - 251.29 MB
New 657.3 ms (-7%) 59000.0000 (-6%) - - 236.35 MB (-6%)
Old Run string-tagcloud 723.0 ms 133083.3333 102500.0000 100333.3333 875.09 MB
New 262.3 ms (-64%) 26333.3333 (-80%) 1750.0000 (-98%) 250.0000 (-100%) 115.38 MB (-87%)
Old Run string-unpack-code 214.7 ms 31750.0000 7750.0000 1250.0000 135.73 MB
New 202.4 ms (-6%) 28250.0000 (-11%) 8250.0000 (+6%) 1500.0000 (+20%) 123.15 MB (-9%)
Old Run string-validate-input 3,346.4 ms 1365166.6667 1333916.6667 1332416.6667 6255.29 MB
New 261.4 ms (-92%) 20750.0000 (-98%) 250.0000 (-100%) - 86.94 MB (-99%)

Jint.Benchmark.ArrayBenchmark

Diff Method N Mean Gen 0 Allocated
Old Slice 100 795.7 us 152.3438 624.22 KB
New 790.1 us (-1%) 150.3906 (-1%) 617.19 KB (-1%)
Old Concat 100 930.9 us 169.9219 696.09 KB
New 902.6 us (-3%) 166.9922 (-2%) 686.72 KB (-1%)
Old Unshift 100 34,700.5 us 3687.5000 15218.75 KB
New 33,541.3 us (-3%) 3687.5000 (0%) 15214.06 KB (0%)
Old Push 100 23,786.0 us 1406.2500 5852.34 KB
New 22,231.2 us (-7%) 1406.2500 (0%) 5847.66 KB (0%)
Old Index 100 22,718.1 us 1250.0000 5177.34 KB
New 21,100.1 us (-7%) 1250.0000 (0%) 5172.66 KB (0%)
Old Map 100 4,594.3 us 1718.7500 7060.16 KB
New 4,266.1 us (-7%) 1531.2500 (-11%) 6285.16 KB (-11%)
Old Apply 100 1,041.4 us 183.5938 758.59 KB
New 1,079.6 us (+4%) 183.5938 (0%) 753.91 KB (-1%)
Old JsonStringifyParse 100 5,316.9 us 1289.0625 5284.38 KB
New 5,353.6 us (+1%) 1250.0000 (-3%) 5144.53 KB (-3%)

Jint.Benchmark.ArrayStressBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Jint 20 1.780 s 94250.0000 14000.0000 394.35 MB
New 1.854 s (+4%) 93250.0000 (-1%) 13000.0000 (-7%) 388.02 MB (-2%)

Jint.Benchmark.EvaluationBenchmark

Diff Method N Mean Gen 0 Allocated
Old Jint 20 1.641 ms 140.6250 583.75 KB
New 1.657 ms (+1%) 138.6719 (-1%) 569.69 KB (-2%)

Jint.Benchmark.LinqJsBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Jint 10 74.88 ms 5250.0000 2500.0000 31.05 MB
New 71.47 ms (-5%) 5125.0000 (-2%) 2562.5000 (+3%) 30.86 MB (-1%)

Jint.Benchmark.MinimalScriptBenchmark

Diff Method N Mean Gen 0 Allocated
Old Jint 10 22.41 us 8.5144 34.92 KB
New 24.07 us (+7%) 8.5144 (0%) 34.92 KB (0%)

Jint.Benchmark.StringIndexingBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Jint 1 2.544 s 45500.0000 250.0000 182.66 MB
New 2.634 s (+4%) 40500.0000 (-11%) 250.0000 (0%) 162.98 MB (-11%)

Jint.Benchmark.UncacheableExpressionsBenchmark

Diff Method N Mean Gen 0 Gen 1 Allocated
Old Benchmark 500 585.2 ms 100104.1667 29208.3333 446.9 MB
New 521.9 ms (-11%) 100000.0000 (0%) 1312.5000 (-96%) 400.31 MB (-10%)

@lahma lahma changed the title WIP Introduce JsString and support efficient string concatenation Introduce JsString, JsBoolean etc and support efficient string concatenation Jan 10, 2018
@sebastienros sebastienros merged commit e0d2e2f into sebastienros:dev Jan 10, 2018
@lahma lahma deleted the perf/stringvalue branch January 10, 2018 20:28
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