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

Improve array access performance #1625

Merged
merged 2 commits into from
Aug 29, 2023

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Aug 28, 2023

  • always have JsValue in array and use sparse as helper to remove type checks
  • faster paths for HasProperty against JsArray
  • remove JsArray constructor taking PropertyDescriptor[]

BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.23531.1001)
AMD Ryzen 9 5950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK=8.0.100-preview.7.23376.3
  [Host]     : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2
  DefaultJob : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2


Jint.Benchmark.ArrayBenchmark

Diff Method Toolchain N Mean Error Allocated
Old Slice Default 100 254.7 μs 1.14 μs 253.13 KB
New Default 248.8 μs (-2%) 0.89 μs 253.13 KB (0%)
Old Concat Default 100 370.6 μs 0.83 μs 345.31 KB
New Default 352.1 μs (-5%) 0.86 μs 345.31 KB (0%)
Old Unshift Default 100 9,286.4 μs 33.91 μs 3490.63 KB
New Default 8,072.0 μs (-13%) 36.66 μs 3490.63 KB (0%)
Old Push Default 100 5,120.0 μs 15.08 μs 850.79 KB
New Default 4,920.7 μs (-4%) 15.89 μs 850.79 KB (0%)
Old Index Default 100 3,659.3 μs 22.31 μs 778.91 KB
New Default 3,801.0 μs (+4%) 60.79 μs 778.91 KB (0%)
Old Map Default 100 2,118.3 μs 12.55 μs 3107.03 KB
New Default 2,188.5 μs (+3%) 9.72 μs 3107.03 KB (0%)
Old Apply Default 100 365.4 μs 1.41 μs 360.16 KB
New Default 325.5 μs (-11%) 0.95 μs 360.16 KB (0%)
Old JsonStringifyParse Default 100 1,215.9 μs 3.24 μs 989.06 KB
New Default 1,162.1 μs (-4%) 3.82 μs 989.06 KB (0%)
Old FilterWithString Default 100 20,864.1 μs 95.51 μs 31775.27 KB
New Default 22,257.2 μs (+7%) 129.98 μs 31775.27 KB (0%)

Jint.Benchmark.ArrayStressBenchmark

Diff Method Toolchain Mean Error Allocated
Old Execute Default 12.85 ms 0.023 ms 7.18 MB
New Default 11.34 ms (-12%) 0.025 ms 6.94 MB (-3%)
Old Execute_ParsedScript Default 12.96 ms 0.023 ms 7.15 MB
New Default 10.85 ms (-16%) 0.035 ms 6.92 MB (-3%)

Jint.Benchmark.DromaeoBenchmark

Diff Method Toolchain FileName Mean Error Allocated
Old Run Default dromaeo-3d-cube 29.956 ms 0.0460 ms 6265.54 KB
New Default 29.517 ms (-1%) 0.0581 ms 6265.54 KB (0%)
Old Run Default dromaeo-core-eval 7.214 ms 0.0609 ms 321.1 KB
New Default 6.697 ms (-7%) 0.0137 ms 321.1 KB (0%)
Old Run Default dromaeo-object-array 83.338 ms 0.4098 ms 101708.39 KB
New Default 68.481 ms (-18%) 0.2054 ms 100749.51 KB (-1%)
Old Run Default droma(...)egexp [21] 289.978 ms 1.1322 ms 171264.47 KB
New Default 290.800 ms (0%) 0.8853 ms 171297.42 KB (0%)
Old Run Default droma(...)tring [21] 448.547 ms 27.2853 ms 1322093.77 KB
New Default 459.237 ms (+2%) 29.4718 ms 1322138.92 KB (0%)
Old Run Default droma(...)ase64 [21] 68.534 ms 0.2781 ms 6699.75 KB
New Default 68.975 ms (+1%) 0.1983 ms 6698.6 KB (0%)
Old Run Default dromaeo-3d-cube 30.105 ms 0.0458 ms 5974.54 KB
New Default 29.019 ms (-4%) 0.0426 ms 5974.53 KB (0%)
Old Run Default dromaeo-core-eval 6.495 ms 0.0169 ms 308.54 KB
New Default 6.841 ms (+5%) 0.0122 ms 308.54 KB (0%)
Old Run Default dromaeo-object-array 84.508 ms 0.2758 ms 101669.45 KB
New Default 69.313 ms (-18%) 0.1942 ms 100709.38 KB (-1%)
Old Run Default droma(...)egexp [21] 279.014 ms 1.0018 ms 172046.3 KB
New Default 281.455 ms (+1%) 0.6894 ms 165644.37 KB (-4%)
Old Run Default droma(...)tring [21] 454.885 ms 28.6828 ms 1321999.77 KB
New Default 455.295 ms (0%) 31.4452 ms 1322001.15 KB (0%)
Old Run Default droma(...)ase64 [21] 66.898 ms 0.1182 ms 6612.38 KB
New Default 66.510 ms (-1%) 0.1254 ms 6612.9 KB (0%)

* always have JsValue in array and use sparse as helper to remove type checks
* faster paths for HasProperty against JsArray
* remove JsArray constructor taking PropertyDescriptor[]
@sebastienros
Copy link
Owner

They threw you some performance challenges ;)

@lahma
Copy link
Collaborator Author

lahma commented Aug 28, 2023

Just an area we're lagging a bit behind the other engines. Trying to even up a bit...

@lahma lahma marked this pull request as ready for review August 29, 2023 16:32
@lahma
Copy link
Collaborator Author

lahma commented Aug 29, 2023

"Feels faster", tests pass, YOLO.

@lahma lahma merged commit 553fdb8 into sebastienros:main Aug 29, 2023
3 checks passed
@lahma lahma deleted the faster-array-has-property branch August 29, 2023 16:42
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