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

[Merged by Bors] - Implement Hidden classes #2723

Closed
wants to merge 1 commit into from

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented Mar 22, 2023

This PR implements Hidden Classes, I named them as Shapes (like Spidermonkey does), calling them maps like v8 seems confusing because there already is a JS builtin, likewise with Hidden classes since there are already classes in JS.

There are two types of shapes: shared shapes that create the transition tree, and are shared between objects, this is mainly intended for user defined objects this makes more sense because shapes can create transitions trees, doing that for the builtins seems wasteful (unless users wanted to creating an object with the same property names and the same property attributes in the same order... which seems unlikely). That's why I added unique shapes, only one object has it. This is similar to previous solution, but this architecture enables us to use inline caching.

There will probably be a performance hit until we implement inline caching.

There still a lot of work that needs to be done, on this:

  • Move Property Attributes to shape
  • Move Prototype to shape
  • Move extensible flag to shape, On further evaluation this doesn't give any benefit (at least right now), since it isn't used by inline caching also adding one more transition.
  • Implement delete for unique shapes.
  • If the chain is too long we should probably convert it into a unique shape
    • Figure out threshold (maybe more that 256 properties ?) curently set to an arbitrary number (1024)
  • Implement shared property table between shared shapes
  • Add code Document
  • Varying size storage for properties (get+set = 2, data = 1)
  • Add shapes to more object:
    • ordinary object
    • Arrays
    • Functions
    • Other builtins
  • Add shapes.md doc explaining shapes in depth with mermaid diagrams :)
  • Add $boa.shape module
  • $boa.shape.id(o)
  • $boa.shape.type(o)
  • $boa.shape.same(o1, o2)
  • add doc to boa_object.md

@HalidOdat HalidOdat added execution Issues or PRs related to code execution run-benchmark Label used to run banchmarks on PRs labels Mar 22, 2023
@jasonwilliams
Copy link
Member

😮😮😮

@codecov
Copy link

codecov bot commented Mar 23, 2023

Codecov Report

Merging #2723 (01f244d) into main (1f4ff6d) will increase coverage by 0.01%.
The diff coverage is 78.90%.

❗ Current head 01f244d differs from pull request most recent head a62710c. Consider uploading reports for the commit a62710c to get more accurate results

@@            Coverage Diff             @@
##             main    #2723      +/-   ##
==========================================
+ Coverage   50.95%   50.97%   +0.01%     
==========================================
  Files         419      423       +4     
  Lines       41940    41751     -189     
==========================================
- Hits        21372    21281      -91     
+ Misses      20568    20470      -98     
Impacted Files Coverage Δ
boa_cli/src/debug/mod.rs 0.00% <0.00%> (ø)
boa_cli/src/debug/shape.rs 0.00% <0.00%> (ø)
boa_engine/src/error.rs 32.93% <0.00%> (-3.33%) ⬇️
boa_engine/src/object/builtins/jsdataview.rs 0.00% <0.00%> (ø)
boa_engine/src/object/builtins/jsdate.rs 0.00% <0.00%> (ø)
boa_engine/src/object/builtins/jsgenerator.rs 0.00% <0.00%> (ø)
boa_engine/src/object/builtins/jsmap.rs 0.00% <0.00%> (ø)
boa_engine/src/object/builtins/jspromise.rs 0.00% <0.00%> (ø)
boa_engine/src/object/builtins/jsproxy.rs 0.00% <0.00%> (ø)
boa_engine/src/object/internal_methods/global.rs 50.34% <0.00%> (ø)
... and 76 more

... and 101 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

github-actions bot commented Mar 23, 2023

Test262 conformance changes

Test result main count PR count difference
Total 94,593 94,593 0
Passed 73,210 73,209 -1
Ignored 17,532 17,532 0
Failed 3,851 3,852 +1
Panics 0 1 +1
Conformance 77.39% 77.39% -0.00%
New panics (1):
test/built-ins/WeakSet/prototype/add/adds-object-element.js (previously Passed)

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as duplicate.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions
Copy link

Benchmark for 7e63a54

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 549.1±1.69ns 612.5±1.44ns +11.55%
Arithmetic operations (Execution) 375.0±0.23ns 373.2±0.34ns -0.48%
Arithmetic operations (Parser) 7.1±0.01µs 7.0±0.01µs -1.41%
Array access (Compiler) 1597.3±2.21ns 1784.7±4.23ns +11.73%
Array access (Execution) 7.0±0.01µs 9.4±0.02µs +34.29%
Array access (Parser) 14.5±0.01µs 14.6±0.03µs +0.69%
Array creation (Compiler) 2.3±0.00µs 2.6±0.01µs +13.04%
Array creation (Execution) 992.7±1.35µs 1087.0±2.09µs +9.50%
Array creation (Parser) 17.5±0.02µs 17.5±0.03µs 0.00%
Array pop (Compiler) 4.5±0.02µs 4.7±0.02µs +4.44%
Array pop (Execution) 598.1±9.23µs 724.8±1.01µs +21.18%
Array pop (Parser) 155.5±0.22µs 155.7±0.57µs +0.13%
Boolean Object Access (Compiler) 1178.6±1.64ns 1251.3±2.46ns +6.17%
Boolean Object Access (Execution) 4.0±0.15µs 5.9±0.04µs +47.50%
Boolean Object Access (Parser) 18.2±0.01µs 18.3±0.03µs +0.55%
Clean js (Compiler) 4.7±0.01µs 5.2±0.01µs +10.64%
Clean js (Execution) 584.9±3.79µs 819.5±3.47µs +40.11%
Clean js (Parser) 36.9±0.04µs 37.0±0.04µs +0.27%
Create Realm 436.0±1.21µs 695.2±1.16µs +59.45%
Dynamic Object Property Access (Compiler) 1921.9±5.41ns 2.1±0.00µs +9.27%
Dynamic Object Property Access (Execution) 4.4±0.01µs 6.2±0.02µs +40.91%
Dynamic Object Property Access (Parser) 13.0±0.02µs 13.0±0.02µs 0.00%
Fibonacci (Compiler) 2.9±0.01µs 3.2±0.01µs +10.34%
Fibonacci (Execution) 976.1±2.22µs 1227.6±5.44µs +25.77%
Fibonacci (Parser) 20.7±0.03µs 20.8±0.03µs +0.48%
For loop (Compiler) 2.6±0.01µs 2.9±0.01µs +11.54%
For loop (Execution) 15.5±0.13µs 17.7±0.07µs +14.19%
For loop (Parser) 17.7±0.04µs 17.9±0.03µs +1.13%
Mini js (Compiler) 4.2±0.01µs 4.6±0.02µs +9.52%
Mini js (Execution) 564.7±12.32µs 757.3±4.56µs +34.11%
Mini js (Parser) 32.3±0.04µs 32.4±0.03µs +0.31%
Number Object Access (Compiler) 1103.4±2.58ns 1177.3±2.78ns +6.70%
Number Object Access (Execution) 3.0±0.00µs 4.5±0.02µs +50.00%
Number Object Access (Parser) 13.9±0.02µs 13.9±0.02µs 0.00%
Object Creation (Compiler) 1705.8±2.53ns 1889.6±3.97ns +10.78%
Object Creation (Execution) 4.1±0.01µs 5.9±0.01µs +43.90%
Object Creation (Parser) 11.3±0.02µs 11.4±0.12µs +0.88%
RegExp (Compiler) 1907.6±4.93ns 2.1±0.01µs +10.09%
RegExp (Execution) 11.8±0.09µs 14.4±0.04µs +22.03%
RegExp (Parser) 12.6±0.02µs 12.6±0.02µs 0.00%
RegExp Creation (Compiler) 1686.0±2.67ns 1867.8±3.24ns +10.78%
RegExp Creation (Execution) 8.5±0.02µs 10.2±0.03µs +20.00%
RegExp Creation (Parser) 10.7±0.03µs 10.6±0.01µs -0.93%
RegExp Literal (Compiler) 1906.2±6.57ns 2.1±0.01µs +10.17%
RegExp Literal (Execution) 11.9±0.06µs 14.4±0.04µs +21.01%
RegExp Literal (Parser) 13.8±0.02µs 13.7±0.03µs -0.72%
RegExp Literal Creation (Compiler) 1695.8±2.77ns 1873.0±7.53ns +10.45%
RegExp Literal Creation (Execution) 8.4±0.02µs 10.1±0.03µs +20.24%
RegExp Literal Creation (Parser) 11.7±0.02µs 11.5±0.03µs -1.71%
Static Object Property Access (Compiler) 1735.2±10.72ns 1911.9±4.07ns +10.18%
Static Object Property Access (Execution) 4.2±0.01µs 6.1±0.03µs +45.24%
Static Object Property Access (Parser) 12.2±0.04µs 12.4±0.02µs +1.64%
String Object Access (Compiler) 1495.7±6.86ns 1557.8±3.33ns +4.15%
String Object Access (Execution) 5.6±0.01µs 8.1±0.03µs +44.64%
String Object Access (Parser) 17.6±0.01µs 17.5±0.02µs -0.57%
String comparison (Compiler) 2.4±0.00µs 2.6±0.01µs +8.33%
String comparison (Execution) 3.7±0.01µs 5.2±0.01µs +40.54%
String comparison (Parser) 14.0±0.02µs 14.1±0.04µs +0.71%
String concatenation (Compiler) 1914.0±7.07ns 2.1±0.00µs +9.72%
String concatenation (Execution) 3.5±0.00µs 4.9±0.02µs +40.00%
String concatenation (Parser) 9.6±0.02µs 9.7±0.02µs +1.04%
String copy (Compiler) 1581.2±3.05ns 1748.6±3.34ns +10.59%
String copy (Execution) 3.3±0.01µs 4.8±0.02µs +45.45%
String copy (Parser) 7.2±0.01µs 7.3±0.01µs +1.39%
Symbols (Compiler) 1155.1±2.62ns 1340.1±7.91ns +16.02%
Symbols (Execution) 3.4±0.01µs 4.9±0.02µs +44.12%
Symbols (Parser) 5.6±0.01µs 5.6±0.02µs 0.00%

@github-actions

This comment was marked as outdated.

@github-actions
Copy link

Benchmark for 759ebd2

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 538.7±0.60ns 614.7±3.76ns +14.11%
Arithmetic operations (Execution) 383.1±0.19ns 380.5±0.18ns -0.68%
Arithmetic operations (Parser) 7.5±0.03µs 7.4±0.03µs -1.33%
Array access (Compiler) 1700.5±1.98ns 1839.9±17.81ns +8.20%
Array access (Execution) 7.7±0.02µs 10.2±0.06µs +32.47%
Array access (Parser) 16.2±0.05µs 16.1±0.04µs -0.62%
Array creation (Compiler) 2.5±0.01µs 2.7±0.02µs +8.00%
Array creation (Execution) 1078.5±5.41µs 1256.0±3.22µs +16.46%
Array creation (Parser) 19.3±0.05µs 19.1±0.03µs -1.04%
Array pop (Compiler) 4.3±0.01µs 4.3±0.01µs 0.00%
Array pop (Execution) 644.9±2.19µs 823.6±3.00µs +27.71%
Array pop (Parser) 167.0±0.18µs 163.0±0.14µs -2.40%
Boolean Object Access (Compiler) 1166.1±1.75ns 1244.7±3.47ns +6.74%
Boolean Object Access (Execution) 4.2±0.00µs 6.4±0.01µs +52.38%
Boolean Object Access (Parser) 20.0±0.03µs 19.5±0.11µs -2.50%
Clean js (Compiler) 5.0±0.01µs 5.5±0.02µs +10.00%
Clean js (Execution) 621.8±2.93µs 895.9±5.58µs +44.08%
Clean js (Parser) 40.7±0.12µs 40.3±0.09µs -0.98%
Create Realm 424.2±1.63µs 681.7±2.80µs +60.70%
Dynamic Object Property Access (Compiler) 2.0±0.00µs 2.1±0.01µs +5.00%
Dynamic Object Property Access (Execution) 4.8±0.02µs 8.3±1.28µs +72.92%
Dynamic Object Property Access (Parser) 14.5±0.03µs 14.4±0.04µs -0.69%
Fibonacci (Compiler) 3.1±0.00µs 3.3±0.01µs +6.45%
Fibonacci (Execution) 1051.0±2.41µs 1306.1±3.49µs +24.27%
Fibonacci (Parser) 22.9±0.04µs 22.7±0.03µs -0.87%
For loop (Compiler) 2.8±0.01µs 3.0±0.01µs +7.14%
For loop (Execution) 16.2±0.03µs 18.5±0.04µs +14.20%
For loop (Parser) 19.4±0.08µs 19.6±0.05µs +1.03%
Mini js (Compiler) 4.5±0.01µs 4.8±0.01µs +6.67%
Mini js (Execution) 574.2±2.26µs 834.4±4.98µs +45.32%
Mini js (Parser) 35.6±0.10µs 35.1±0.12µs -1.40%
Number Object Access (Compiler) 1089.9±2.39ns 1174.3±5.27ns +7.74%
Number Object Access (Execution) 3.2±0.01µs 4.9±0.04µs +53.13%
Number Object Access (Parser) 15.4±0.08µs 15.1±0.04µs -1.95%
Object Creation (Compiler) 1769.8±10.77ns 1943.5±10.30ns +9.81%
Object Creation (Execution) 4.4±0.01µs 7.8±1.11µs +77.27%
Object Creation (Parser) 12.8±0.03µs 12.7±0.04µs -0.78%
RegExp (Compiler) 2.0±0.04µs 2.2±0.00µs +10.00%
RegExp (Execution) 12.2±0.03µs 15.9±0.79µs +30.33%
RegExp (Parser) 13.8±0.03µs 13.7±0.08µs -0.72%
RegExp Creation (Compiler) 1808.4±10.65ns 1926.1±8.08ns +6.51%
RegExp Creation (Execution) 8.6±0.02µs 10.7±0.04µs +24.42%
RegExp Creation (Parser) 11.7±0.04µs 11.7±0.09µs 0.00%
RegExp Literal (Compiler) 2.0±0.01µs 2.2±0.00µs +10.00%
RegExp Literal (Execution) 12.3±0.02µs 15.7±0.39µs +27.64%
RegExp Literal (Parser) 14.8±0.03µs 15.0±0.93µs +1.35%
RegExp Literal Creation (Compiler) 1808.2±8.68ns 1935.5±7.11ns +7.04%
RegExp Literal Creation (Execution) 8.6±0.02µs 10.7±0.04µs +24.42%
RegExp Literal Creation (Parser) 12.5±0.02µs 12.6±0.05µs +0.80%
Static Object Property Access (Compiler) 1802.8±2.35ns 1946.2±9.37ns +7.95%
Static Object Property Access (Execution) 4.6±0.01µs 7.3±0.47µs +58.70%
Static Object Property Access (Parser) 13.7±0.03µs 13.6±0.04µs -0.73%
String Object Access (Compiler) 1512.5±2.93ns 1592.0±6.62ns +5.26%
String Object Access (Execution) 5.8±0.02µs 8.7±0.02µs +50.00%
String Object Access (Parser) 19.2±0.02µs 18.8±0.05µs -2.08%
String comparison (Compiler) 2.5±0.00µs 2.7±0.01µs +8.00%
String comparison (Execution) 4.0±0.01µs 5.3±0.02µs +32.50%
String comparison (Parser) 15.6±0.02µs 15.5±0.03µs -0.64%
String concatenation (Compiler) 2.0±0.00µs 2.2±0.01µs +10.00%
String concatenation (Execution) 3.7±0.00µs 5.1±0.02µs +37.84%
String concatenation (Parser) 10.6±0.02µs 10.5±0.02µs -0.94%
String copy (Compiler) 1650.4±5.47ns 1812.8±7.49ns +9.84%
String copy (Execution) 3.5±0.00µs 4.9±0.03µs +40.00%
String copy (Parser) 8.2±0.02µs 8.1±0.02µs -1.22%
Symbols (Compiler) 1226.4±38.26ns 1383.2±9.79ns +12.79%
Symbols (Execution) 3.6±0.03µs 5.0±0.03µs +38.89%
Symbols (Parser) 6.3±0.02µs 6.2±0.03µs -1.59%

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@HalidOdat
Copy link
Member Author

HalidOdat commented Mar 27, 2023

This is now nearing completion :) Still have some minor things left! But I think this is ready for review now!

Added code documentation as well as a markdown shapes.md (rendered) Explaining with examples (suggest reading it first, it gives a general overview of the shapes architecture :) )

The benchmarks are not looking good, shapes on their own are more of a memory optimization, will be working on inline caching, which should speed up the execution.

@github-actions
Copy link

Benchmark for 9a1cc45

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 568.1±0.58ns 643.1±1076.70ns +13.20%
Arithmetic operations (Execution) 443.9±0.26ns 454.5±0.40ns +2.39%
Arithmetic operations (Parser) 7.1±0.01µs 7.1±0.03µs 0.00%
Array access (Compiler) 1670.4±3.60ns 2.1±3.54µs +25.72%
Array access (Execution) 6.9±0.02µs 7.4±9.68µs +7.25%
Array access (Parser) 14.6±0.04µs 14.8±0.02µs +1.37%
Array creation (Compiler) 2.4±0.00µs 3.7±6.67µs +54.17%
Array creation (Execution) 1005.0±4.45µs 1150.3±806.85µs +14.46%
Array creation (Parser) 17.5±0.03µs 17.7±0.04µs +1.14%
Array pop (Compiler) 4.3±0.01µs 5.5±7.63µs +27.91%
Array pop (Execution) 577.5±0.83µs 690.4±457.78µs +19.55%
Array pop (Parser) 154.1±0.13µs 154.6±0.20µs +0.32%
Boolean Object Access (Compiler) 1210.4±3.40ns 1538.3±2080.03ns +27.09%
Boolean Object Access (Execution) 4.5±0.04µs 5.8±5.84µs +28.89%
Boolean Object Access (Parser) 18.0±0.03µs 18.1±0.02µs +0.56%
Clean js (Compiler) 4.8±0.01µs 7.1±13.69µs +47.92%
Clean js (Execution) 748.7±2.28µs 887.5±505.27µs +18.54%
Clean js (Parser) 36.4±0.05µs 36.9±0.03µs +1.37%
Create Realm 497.8±1.63µs 593.3±1793.22µs +19.18%
Dynamic Object Property Access (Compiler) 1974.6±2.23ns 2.8±6.34µs +41.80%
Dynamic Object Property Access (Execution) 4.3±0.01µs 4.3±6.12µs 0.00%
Dynamic Object Property Access (Parser) 13.1±0.02µs 13.0±0.02µs -0.76%
Fibonacci (Compiler) 3.0±0.01µs 4.0±5.42µs +33.33%
Fibonacci (Execution) 1015.7±2.14µs 892.4±1338.49µs -12.14%
Fibonacci (Parser) 20.6±0.03µs 20.8±0.16µs +0.97%
For loop (Compiler) 2.7±0.02µs 3.6±5.20µs +33.33%
For loop (Execution) 15.1±0.04µs 21.9±50.99µs +45.03%
For loop (Parser) 17.9±0.04µs 18.1±0.03µs +1.12%
Mini js (Compiler) 4.3±0.01µs 7.9±22.25µs +83.72%
Mini js (Execution) 704.4±2.58µs 787.1±3.47µs +11.74%
Mini js (Parser) 31.8±0.04µs 32.4±0.05µs +1.89%
Number Object Access (Compiler) 1138.4±2.44ns 1389.4±1708.24ns +22.05%
Number Object Access (Execution) 3.5±0.01µs 4.3±5.29µs +22.86%
Number Object Access (Parser) 13.6±0.03µs 13.8±0.02µs +1.47%
Object Creation (Compiler) 1769.8±3.02ns 3.9±14.93µs +120.36%
Object Creation (Execution) 4.1±0.01µs 4.0±6.18µs -2.44%
Object Creation (Parser) 11.5±0.02µs 11.5±0.05µs 0.00%
RegExp (Compiler) 1990.5±3.40ns 3.5±11.21µs +75.84%
RegExp (Execution) 12.3±0.04µs 12.6±9.40µs +2.44%
RegExp (Parser) 12.5±0.02µs 12.5±0.02µs 0.00%
RegExp Creation (Compiler) 1772.5±2.81ns 2.1±3.87µs +18.48%
RegExp Creation (Execution) 8.6±0.02µs 9.5±12.45µs +10.47%
RegExp Creation (Parser) 10.5±0.01µs 10.5±0.02µs 0.00%
RegExp Literal (Compiler) 1987.8±3.69ns 2.6±3.72µs +30.80%
RegExp Literal (Execution) 12.2±0.03µs 13.8±16.27µs +13.11%
RegExp Literal (Parser) 13.9±0.02µs 14.1±0.03µs +1.44%
RegExp Literal Creation (Compiler) 1764.8±8.82ns 2.1±3.27µs +18.99%
RegExp Literal Creation (Execution) 8.6±0.03µs 8.6±6.83µs 0.00%
RegExp Literal Creation (Parser) 11.8±0.02µs 11.9±0.03µs +0.85%
Static Object Property Access (Compiler) 1787.7±1.90ns 2.4±4.25µs +34.25%
Static Object Property Access (Execution) 4.2±0.01µs 4.2±6.09µs 0.00%
Static Object Property Access (Parser) 12.4±0.02µs 12.3±0.02µs -0.81%
String Object Access (Compiler) 1535.5±5.35ns 1791.3±2109.41ns +16.66%
String Object Access (Execution) 6.1±0.01µs 8.2±9.51µs +34.43%
String Object Access (Parser) 17.2±0.04µs 17.2±0.03µs 0.00%
String comparison (Compiler) 2.5±0.00µs 3.1±3.77µs +24.00%
String comparison (Execution) 3.8±0.01µs 3.5±5.85µs -7.89%
String comparison (Parser) 13.9±0.01µs 14.1±0.03µs +1.44%
String concatenation (Compiler) 1965.4±2.49ns 3.0±5.40µs +52.64%
String concatenation (Execution) 3.5±0.01µs 4.4±14.70µs +25.71%
String concatenation (Parser) 9.6±0.02µs 9.7±0.02µs +1.04%
String copy (Compiler) 1630.8±5.03ns 2.2±3.76µs +34.90%
String copy (Execution) 3.3±0.01µs 3.1±5.73µs -6.06%
String copy (Parser) 7.2±0.02µs 7.2±0.02µs 0.00%
Symbols (Compiler) 1198.5±1.26ns 1868.5±4402.39ns +55.90%
Symbols (Execution) 3.5±0.02µs 3.3±6.44µs -5.71%
Symbols (Parser) 5.6±0.01µs 5.7±0.02µs +1.79%

@HalidOdat
Copy link
Member Author

HalidOdat commented Apr 13, 2023

Currently the integration with builtin construction is not fully complete, there are still some places that don't utilize direct shape initialization, but I have left it for #2813 which should improve buitin construction! :)

@jasonwilliams
Copy link
Member

I still want to take a second review of this also

@github-actions
Copy link

Benchmark for b066366

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 648.9±1.09ns 652.2±833.61ns +0.51%
Arithmetic operations (Execution) 547.6±0.61ns 560.6±0.65ns +2.37%
Arithmetic operations (Parser) 8.4±0.02µs 8.2±0.01µs -2.38%
Array access (Compiler) 1954.0±3.71ns 2.5±5.30µs +27.94%
Array access (Execution) 8.5±0.02µs 9.6±17.12µs +12.94%
Array access (Parser) 17.4±0.04µs 16.8±0.04µs -3.45%
Array creation (Compiler) 2.8±0.01µs 3.2±4.00µs +14.29%
Array creation (Execution) 1204.6±2.32µs 1368.9±936.20µs +13.64%
Array creation (Parser) 21.3±0.03µs 20.4±0.03µs -4.23%
Array pop (Compiler) 4.9±0.02µs 5.8±7.42µs +18.37%
Array pop (Execution) 702.7±6.39µs 814.3±394.49µs +15.88%
Array pop (Parser) 183.5±0.26µs 176.8±0.27µs -3.65%
Boolean Object Access (Compiler) 1335.4±2.11ns 2.1±6.04µs +57.26%
Boolean Object Access (Execution) 5.7±0.01µs 7.3±11.15µs +28.07%
Boolean Object Access (Parser) 22.0±0.03µs 21.3±0.02µs -3.18%
Clean js (Compiler) 5.6±0.02µs 7.0±8.77µs +25.00%
Clean js (Execution) 900.3±4.16µs 979.9±9.40µs +8.84%
Clean js (Parser) 44.5±0.05µs 43.0±0.08µs -3.37%
Create Realm 639.1±4.69µs 710.8±1892.95µs +11.22%
Dynamic Object Property Access (Compiler) 2.3±0.01µs 2.6±3.58µs +13.04%
Dynamic Object Property Access (Execution) 5.4±0.01µs 4.7±5.78µs -12.96%
Dynamic Object Property Access (Parser) 15.5±0.03µs 15.1±0.02µs -2.58%
Fibonacci (Compiler) 3.5±0.01µs 4.9±8.62µs +40.00%
Fibonacci (Execution) 1245.5±20.55µs 1008.1±1411.89µs -19.06%
Fibonacci (Parser) 25.2±0.04µs 24.2±0.14µs -3.97%
For loop (Compiler) 3.2±0.01µs 4.3±7.11µs +34.37%
For loop (Execution) 18.3±0.07µs 20.4±27.62µs +11.48%
For loop (Parser) 21.9±0.04µs 21.2±0.05µs -3.20%
Mini js (Compiler) 5.1±0.01µs 6.5±8.39µs +27.45%
Mini js (Execution) 851.7±3.92µs 986.1±605.96µs +15.78%
Mini js (Parser) 39.0±0.05µs 37.4±0.08µs -4.10%
Number Object Access (Compiler) 1278.8±2.78ns 1466.1±1232.28ns +14.65%
Number Object Access (Execution) 4.4±0.01µs 4.8±3.98µs +9.09%
Number Object Access (Parser) 16.8±0.02µs 16.4±0.06µs -2.38%
Object Creation (Compiler) 2.1±0.00µs 2.2±2.82µs +4.76%
Object Creation (Execution) 5.1±0.02µs 4.5±7.03µs -11.76%
Object Creation (Parser) 13.8±0.03µs 13.4±0.03µs -2.90%
RegExp (Compiler) 2.4±0.00µs 3.6±9.15µs +50.00%
RegExp (Execution) 14.2±0.03µs 15.5±16.41µs +9.15%
RegExp (Parser) 14.9±0.02µs 14.5±0.03µs -2.68%
RegExp Creation (Compiler) 2.1±0.00µs 2.7±6.02µs +28.57%
RegExp Creation (Execution) 10.0±0.02µs 10.2±10.11µs +2.00%
RegExp Creation (Parser) 12.6±0.03µs 12.2±0.02µs -3.17%
RegExp Literal (Compiler) 2.4±0.00µs 2.8±4.55µs +16.67%
RegExp Literal (Execution) 14.1±0.04µs 14.3±9.12µs +1.42%
RegExp Literal (Parser) 16.3±0.03µs 16.1±0.03µs -1.23%
RegExp Literal Creation (Compiler) 2.1±0.00µs 2.4±3.73µs +14.29%
RegExp Literal Creation (Execution) 10.0±0.06µs 13.3±40.45µs +33.00%
RegExp Literal Creation (Parser) 13.8±0.05µs 13.7±0.03µs -0.72%
Static Object Property Access (Compiler) 2.1±0.01µs 2.4±3.02µs +14.29%
Static Object Property Access (Execution) 5.3±0.01µs 4.7±6.37µs -11.32%
Static Object Property Access (Parser) 14.8±0.05µs 14.3±0.07µs -3.38%
String Object Access (Compiler) 1716.2±4.82ns 1820.1±2177.10ns +6.05%
String Object Access (Execution) 7.7±0.01µs 9.8±12.89µs +27.27%
String Object Access (Parser) 21.2±0.02µs 20.7±0.02µs -2.36%
String comparison (Compiler) 2.9±0.01µs 3.5±3.62µs +20.69%
String comparison (Execution) 4.8±0.02µs 3.8±4.89µs -20.83%
String comparison (Parser) 17.0±0.03µs 16.8±0.03µs -1.18%
String concatenation (Compiler) 2.3±0.00µs 2.9±4.88µs +26.09%
String concatenation (Execution) 4.5±0.01µs 4.6±13.12µs +2.22%
String concatenation (Parser) 11.5±0.02µs 11.3±0.02µs -1.74%
String copy (Compiler) 1913.6±4.11ns 2.2±3.79µs +14.97%
String copy (Execution) 4.2±0.01µs 3.1±4.15µs -26.19%
String copy (Parser) 8.5±0.03µs 8.4±0.01µs -1.18%
Symbols (Compiler) 1423.0±2.70ns 1739.2±3865.25ns +22.22%
Symbols (Execution) 4.5±0.01µs 3.1±4.12µs -31.11%
Symbols (Parser) 6.6±0.01µs 6.4±0.06µs -3.03%

@HalidOdat
Copy link
Member Author

Did some benchmarks on main, shapes and inline-caching branches (the current state of inline-cahing is a WIP)

Main

Richards: 18.5
DeltaBlue: 17.6
RayTrace: 68.1
----
Score (version 7): 28.1

Shapes

Richards: 19.9
DeltaBlue: 23.6
RayTrace: 80.8
----
Score (version 7): 33.6

Shapes + Inline Caching

Richards: 28.4
DeltaBlue: 29.3
RayTrace: 94.8
----
Score (version 7): 42.9
undefined

We can see a pretty big increase in performance, interestingly even just shapes has a big performance increase without inline caching.

@github-actions
Copy link

Benchmark for e2cf294

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 547.9±1.10ns 670.5±1073.40ns +22.38%
Arithmetic operations (Execution) 471.6±0.26ns 472.3±0.30ns +0.15%
Arithmetic operations (Parser) 7.8±0.05µs 7.8±0.03µs 0.00%
Array access (Compiler) 1664.6±2.20ns 1929.8±2191.20ns +15.93%
Array access (Execution) 7.6±0.03µs 7.0±5.46µs -7.89%
Array access (Parser) 17.3±0.04µs 16.9±0.04µs -2.31%
Array creation (Compiler) 2.5±0.01µs 2.4±2.19µs -4.00%
Array creation (Execution) 1104.3±2.08µs 1136.3±8.36µs +2.90%
Array creation (Parser) 20.9±0.21µs 20.5±0.05µs -1.91%
Array pop (Compiler) 4.0±0.02µs 4.6±2.69µs +15.00%
Array pop (Execution) 632.7±2.13µs 697.0±4.00µs +10.16%
Array pop (Parser) 170.6±0.52µs 172.9±7.21µs +1.35%
Boolean Object Access (Compiler) 1204.0±2.97ns 1290.1±701.89ns +7.15%
Boolean Object Access (Execution) 5.2±0.01µs 6.9±13.02µs +32.69%
Boolean Object Access (Parser) 21.4±0.22µs 21.3±0.81µs -0.47%
Clean js (Compiler) 5.1±0.01µs 6.1±7.00µs +19.61%
Clean js (Execution) 786.8±2.90µs 882.8±219.64µs +12.20%
Clean js (Parser) 43.2±0.07µs 42.6±0.20µs -1.39%
Create Realm 538.0±6.43µs 539.8±1401.60µs +0.33%
Dynamic Object Property Access (Compiler) 1986.3±2.83ns 2.2±2.83µs +10.76%
Dynamic Object Property Access (Execution) 4.9±0.00µs 4.1±4.18µs -16.33%
Dynamic Object Property Access (Parser) 15.6±0.03µs 15.2±0.04µs -2.56%
Fibonacci (Compiler) 3.1±0.01µs 3.7±4.13µs +19.35%
Fibonacci (Execution) 1141.9±23.92µs 881.0±707.81µs -22.85%
Fibonacci (Parser) 24.5±0.04µs 23.9±0.09µs -2.45%
For loop (Compiler) 2.8±0.01µs 3.4±3.99µs +21.43%
For loop (Execution) 16.3±0.05µs 17.4±17.87µs +6.75%
For loop (Parser) 21.3±0.12µs 20.8±0.27µs -2.35%
Mini js (Compiler) 4.5±0.01µs 5.5±5.70µs +22.22%
Mini js (Execution) 750.4±3.83µs 821.6±6.03µs +9.49%
Mini js (Parser) 38.0±0.23µs 37.5±0.70µs -1.32%
Number Object Access (Compiler) 1130.3±5.50ns 1270.2±1620.46ns +12.38%
Number Object Access (Execution) 4.0±0.04µs 4.5±3.79µs +12.50%
Number Object Access (Parser) 16.5±0.08µs 15.9±0.07µs -3.64%
Object Creation (Compiler) 1782.4±3.60ns 2.2±2.68µs +23.43%
Object Creation (Execution) 4.6±0.02µs 4.2±6.31µs -8.70%
Object Creation (Parser) 13.8±0.06µs 13.4±0.03µs -2.90%
RegExp (Compiler) 2.0±0.00µs 2.2±2.35µs +10.00%
RegExp (Execution) 12.8±0.03µs 12.0±5.97µs -6.25%
RegExp (Parser) 14.9±0.05µs 14.5±0.02µs -2.68%
RegExp Creation (Compiler) 1767.7±4.31ns 2.3±3.04µs +30.11%
RegExp Creation (Execution) 9.1±0.04µs 8.6±6.24µs -5.49%
RegExp Creation (Parser) 12.6±0.03µs 12.2±0.03µs -3.17%
RegExp Literal (Compiler) 1991.3±3.53ns 2.3±2.21µs +15.50%
RegExp Literal (Execution) 12.9±0.05µs 12.4±6.91µs -3.88%
RegExp Literal (Parser) 15.7±0.03µs 15.6±0.03µs -0.64%
RegExp Literal Creation (Compiler) 1802.2±2.92ns 2.1±2.63µs +16.52%
RegExp Literal Creation (Execution) 9.1±0.02µs 8.9±8.77µs -2.20%
RegExp Literal Creation (Parser) 13.3±0.03µs 13.1±0.02µs -1.50%
Static Object Property Access (Compiler) 1807.4±3.92ns 2.2±3.49µs +21.72%
Static Object Property Access (Execution) 4.7±0.01µs 4.2±5.13µs -10.64%
Static Object Property Access (Parser) 14.9±0.04µs 14.5±0.38µs -2.68%
String Object Access (Compiler) 1557.7±6.20ns 2.1±5.26µs +34.81%
String Object Access (Execution) 6.8±0.02µs 7.8±4.57µs +14.71%
String Object Access (Parser) 21.0±0.04µs 20.1±0.02µs -4.29%
String comparison (Compiler) 2.6±0.00µs 3.6±7.96µs +38.46%
String comparison (Execution) 4.2±0.02µs 3.1±3.47µs -26.19%
String comparison (Parser) 17.0±0.03µs 16.5±0.02µs -2.94%
String concatenation (Compiler) 2.0±0.00µs 2.2±2.30µs +10.00%
String concatenation (Execution) 4.0±0.01µs 3.0±4.02µs -25.00%
String concatenation (Parser) 11.7±0.26µs 11.3±0.02µs -3.42%
String copy (Compiler) 1675.8±2.18ns 1986.7±2710.75ns +18.55%
String copy (Execution) 3.8±0.02µs 2.7±3.87µs -28.95%
String copy (Parser) 8.8±0.01µs 8.6±0.01µs -2.27%
Symbols (Compiler) 1204.5±2.13ns 1387.6±2004.91ns +15.20%
Symbols (Execution) 3.9±0.02µs 2.7±3.31µs -30.77%
Symbols (Parser) 6.8±0.02µs 6.6±0.06µs -2.94%

@github-actions
Copy link

Benchmark for 725bbb8

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 680.5±4.34ns 804.2±1569.13ns +18.18%
Arithmetic operations (Execution) 545.8±1.20ns 546.4±3.05ns +0.11%
Arithmetic operations (Parser) 8.0±0.11µs 8.0±0.07µs 0.00%
Array access (Compiler) 2.0±0.03µs 2.2±3.62µs +10.00%
Array access (Execution) 8.5±0.04µs 8.4±9.50µs -1.18%
Array access (Parser) 16.2±0.08µs 16.4±0.12µs +1.23%
Array creation (Compiler) 3.0±0.03µs 3.8±6.97µs +26.67%
Array creation (Execution) 1158.5±7.39µs 1251.9±24.18µs +8.06%
Array creation (Parser) 19.6±0.11µs 19.7±0.11µs +0.51%
Array pop (Compiler) 5.4±0.02µs 5.7±5.95µs +5.56%
Array pop (Execution) 662.3±4.75µs 753.2±11.50µs +13.72%
Array pop (Parser) 177.7±1.56µs 180.2±1.64µs +1.41%
Boolean Object Access (Compiler) 1342.5±6.06ns 1472.2±1175.78ns +9.66%
Boolean Object Access (Execution) 5.8±0.02µs 7.0±8.05µs +20.69%
Boolean Object Access (Parser) 20.6±0.18µs 20.8±0.09µs +0.97%
Clean js (Compiler) 5.8±0.03µs 6.9±9.65µs +18.97%
Clean js (Execution) 932.3±15.40µs 961.9±25.10µs +3.17%
Clean js (Parser) 41.8±0.26µs 41.5±0.23µs -0.72%
Create Realm 639.2±3.78µs 698.9±1832.59µs +9.34%
Dynamic Object Property Access (Compiler) 2.4±0.01µs 2.6±3.57µs +8.33%
Dynamic Object Property Access (Execution) 5.5±0.06µs 5.7±10.89µs +3.64%
Dynamic Object Property Access (Parser) 14.5±0.06µs 14.5±0.09µs 0.00%
Fibonacci (Compiler) 3.6±0.01µs 5.5±15.03µs +52.78%
Fibonacci (Execution) 1253.0±6.47µs 1032.4±1431.00µs -17.61%
Fibonacci (Parser) 23.2±0.18µs 23.6±0.13µs +1.72%
For loop (Compiler) 3.3±0.02µs 4.4±8.29µs +33.33%
For loop (Execution) 18.6±0.10µs 21.4±30.69µs +15.05%
For loop (Parser) 20.1±0.09µs 20.3±0.22µs +1.00%
Mini js (Compiler) 5.2±0.04µs 7.0±9.53µs +34.62%
Mini js (Execution) 855.3±4.88µs 960.4±454.06µs +12.29%
Mini js (Parser) 36.3±0.18µs 36.3±0.18µs 0.00%
Number Object Access (Compiler) 1280.6±6.66ns 1498.3±1470.21ns +17.00%
Number Object Access (Execution) 4.5±0.02µs 4.8±3.87µs +6.67%
Number Object Access (Parser) 15.6±0.10µs 15.7±0.18µs +0.64%
Object Creation (Compiler) 2.1±0.02µs 2.5±3.78µs +19.05%
Object Creation (Execution) 5.2±0.03µs 4.9±7.39µs -5.77%
Object Creation (Parser) 12.7±0.06µs 12.9±0.06µs +1.57%
RegExp (Compiler) 2.4±0.02µs 2.6±3.48µs +8.33%
RegExp (Execution) 14.6±0.06µs 14.6±10.14µs 0.00%
RegExp (Parser) 13.9±0.07µs 14.1±0.08µs +1.44%
RegExp Creation (Compiler) 2.1±0.02µs 2.1±3.19µs 0.00%
RegExp Creation (Execution) 10.2±0.06µs 9.8±7.70µs -3.92%
RegExp Creation (Parser) 11.6±0.12µs 11.9±0.11µs +2.59%
RegExp Literal (Compiler) 2.4±0.02µs 2.4±3.63µs 0.00%
RegExp Literal (Execution) 14.5±0.10µs 13.8±8.71µs -4.83%
RegExp Literal (Parser) 15.7±0.08µs 15.5±0.17µs -1.27%
RegExp Literal Creation (Compiler) 2.1±0.01µs 2.1±3.26µs 0.00%
RegExp Literal Creation (Execution) 10.2±0.06µs 11.0±16.76µs +7.84%
RegExp Literal Creation (Parser) 13.3±0.07µs 13.4±0.14µs +0.75%
Static Object Property Access (Compiler) 2.1±0.02µs 2.7±4.53µs +28.57%
Static Object Property Access (Execution) 5.3±0.05µs 4.9±6.10µs -7.55%
Static Object Property Access (Parser) 13.6±0.09µs 13.8±0.07µs +1.47%
String Object Access (Compiler) 1733.1±9.00ns 2.1±2.30µs +21.17%
String Object Access (Execution) 7.5±0.02µs 8.5±9.52µs +13.33%
String Object Access (Parser) 19.8±0.14µs 20.0±0.22µs +1.01%
String comparison (Compiler) 3.0±0.02µs 3.4±4.00µs +13.33%
String comparison (Execution) 4.8±0.05µs 3.8±5.00µs -20.83%
String comparison (Parser) 15.8±0.09µs 15.9±0.06µs +0.63%
String concatenation (Compiler) 2.4±0.02µs 2.9±4.45µs +20.83%
String concatenation (Execution) 4.5±0.02µs 3.6±5.41µs -20.00%
String concatenation (Parser) 10.7±0.08µs 10.8±0.03µs +0.93%
String copy (Compiler) 1998.6±13.69ns 3.2±8.24µs +60.11%
String copy (Execution) 4.3±0.02µs 3.2±4.24µs -25.58%
String copy (Parser) 7.9±0.14µs 8.0±0.03µs +1.27%
Symbols (Compiler) 1445.1±13.50ns 1746.9±3609.14ns +20.88%
Symbols (Execution) 4.4±0.03µs 5.0±16.90µs +13.64%
Symbols (Parser) 6.2±0.04µs 6.3±0.04µs +1.61%

@HalidOdat HalidOdat mentioned this pull request Apr 23, 2023
28 tasks
@github-actions
Copy link

Benchmark for 401047e

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 657.6±11.29ns 762.8±1496.87ns +16.00%
Arithmetic operations (Execution) 531.1±11.23ns 524.3±15.01ns -1.28%
Arithmetic operations (Parser) 7.7±0.28µs 7.8±0.25µs +1.30%
Array access (Compiler) 1981.9±17.64ns 2.0±3.11µs +0.91%
Array access (Execution) 8.1±0.31µs 7.8±7.57µs -3.70%
Array access (Parser) 16.9±0.31µs 15.7±0.56µs -7.10%
Array creation (Compiler) 2.8±0.06µs 3.7±6.08µs +32.14%
Array creation (Execution) 1160.9±26.10µs 1266.0±1250.32µs +9.05%
Array creation (Parser) 20.3±0.63µs 18.8±0.70µs -7.39%
Array pop (Compiler) 4.9±0.16µs 6.2±9.33µs +26.53%
Array pop (Execution) 660.0±16.63µs 1029.5±3322.97µs +55.98%
Array pop (Parser) 178.7±3.38µs 167.9±6.72µs -6.04%
Boolean Object Access (Compiler) 1326.0±15.78ns 1558.9±1968.24ns +17.56%
Boolean Object Access (Execution) 5.4±0.09µs 5.7±4.46µs +5.56%
Boolean Object Access (Parser) 21.1±0.90µs 19.9±0.92µs -5.69%
Clean js (Compiler) 5.5±0.15µs 6.8±9.44µs +23.64%
Clean js (Execution) 853.9±10.67µs 960.1±608.22µs +12.44%
Clean js (Parser) 41.4±1.39µs 39.2±1.42µs -5.31%
Create Realm 596.3±18.33µs 746.2±1942.76µs +25.14%
Dynamic Object Property Access (Compiler) 2.3±0.04µs 2.8±4.22µs +21.74%
Dynamic Object Property Access (Execution) 5.4±0.04µs 4.3±5.64µs -20.37%
Dynamic Object Property Access (Parser) 14.8±0.49µs 14.7±0.20µs -0.68%
Fibonacci (Compiler) 3.5±0.02µs 4.7±9.82µs +34.29%
Fibonacci (Execution) 1193.6±33.41µs 986.9±1276.45µs -17.32%
Fibonacci (Parser) 24.3±0.53µs 22.5±0.93µs -7.41%
For loop (Compiler) 3.2±0.07µs 4.6±13.78µs +43.75%
For loop (Execution) 18.5±0.52µs 21.4±29.33µs +15.68%
For loop (Parser) 20.8±0.49µs 19.3±0.66µs -7.21%
Mini js (Compiler) 4.9±0.10µs 7.0±10.33µs +42.86%
Mini js (Execution) 796.3±18.25µs 826.5±26.85µs +3.79%
Mini js (Parser) 36.7±1.22µs 34.0±1.58µs -7.36%
Number Object Access (Compiler) 1264.3±25.71ns 1208.2±1172.50ns -4.44%
Number Object Access (Execution) 4.2±0.08µs 4.4±4.32µs +4.76%
Number Object Access (Parser) 15.7±0.69µs 15.1±0.56µs -3.82%
Object Creation (Compiler) 2.1±0.05µs 2.5±3.99µs +19.05%
Object Creation (Execution) 5.1±0.11µs 4.4±6.38µs -13.73%
Object Creation (Parser) 12.8±0.50µs 12.9±0.30µs +0.78%
RegExp (Compiler) 2.4±0.01µs 2.7±5.17µs +12.50%
RegExp (Execution) 13.6±0.37µs 15.7±29.47µs +15.44%
RegExp (Parser) 14.4±0.42µs 13.1±0.45µs -9.03%
RegExp Creation (Compiler) 2.0±0.04µs 2.7±5.42µs +35.00%
RegExp Creation (Execution) 9.6±0.22µs 9.7±10.68µs +1.04%
RegExp Creation (Parser) 11.8±0.41µs 11.5±0.26µs -2.54%
RegExp Literal (Compiler) 2.3±0.04µs 3.1±6.48µs +34.78%
RegExp Literal (Execution) 13.7±0.34µs 13.5±9.63µs -1.46%
RegExp Literal (Parser) 15.1±0.65µs 15.0±0.50µs -0.66%
RegExp Literal Creation (Compiler) 2.1±0.02µs 2.5±3.26µs +19.05%
RegExp Literal Creation (Execution) 9.7±0.21µs 8.9±6.25µs -8.25%
RegExp Literal Creation (Parser) 12.7±0.53µs 12.9±0.31µs +1.57%
Static Object Property Access (Compiler) 2.1±0.05µs 2.7±4.76µs +28.57%
Static Object Property Access (Execution) 5.3±0.11µs 4.4±6.08µs -16.98%
Static Object Property Access (Parser) 14.0±0.53µs 13.6±0.39µs -2.86%
String Object Access (Compiler) 1675.8±54.10ns 1983.2±2027.37ns +18.34%
String Object Access (Execution) 7.1±0.12µs 9.5±19.39µs +33.80%
String Object Access (Parser) 20.0±0.67µs 19.4±0.59µs -3.00%
String comparison (Compiler) 2.9±0.10µs 4.1±5.91µs +41.38%
String comparison (Execution) 4.7±0.12µs 3.7±5.08µs -21.28%
String comparison (Parser) 16.0±0.65µs 15.3±0.56µs -4.37%
String concatenation (Compiler) 2.4±0.03µs 3.3±5.42µs +37.50%
String concatenation (Execution) 4.5±0.10µs 3.5±5.45µs -22.22%
String concatenation (Parser) 10.6±0.36µs 10.2±0.37µs -3.77%
String copy (Compiler) 1853.2±81.39ns 2.5±5.20µs +34.90%
String copy (Execution) 4.3±0.07µs 3.2±4.68µs -25.58%
String copy (Parser) 7.8±0.30µs 7.6±0.28µs -2.56%
Symbols (Compiler) 1384.6±42.73ns 1771.6±3785.38ns +27.95%
Symbols (Execution) 4.2±0.11µs 3.1±4.19µs -26.19%
Symbols (Parser) 6.1±0.23µs 5.7±0.22µs -6.56%

@jasonwilliams
Copy link
Member

Array pop (Execution) 660.0±16.63µs 1029.5±3322.97µs +55.98%

Any idea why this one has gone up so much?

@raskad
Copy link
Member

raskad commented Apr 24, 2023

Array pop (Execution) 660.0±16.63µs 1029.5±3322.97µs +55.98%

Any idea why this one has gone up so much?

I suspect that is because the test is basically just adding many index properties to an array while creating the array literal. This process is now creating the relevant shapes which is where the overhead comes from.

@HalidOdat
Copy link
Member Author

HalidOdat commented Apr 25, 2023

Benchmark:

(function () {
  let testArray = [ /* Many elements */ ];

  while (testArray.length > 0) {
    testArray.pop();
  }
  return testArray;
})();

I suspect that is because the test is basically just adding many index properties to an array while creating the array literal. This process is now creating the relevant shapes which is where the overhead comes from.

Indexed properties are special as they don't cause a shape transition, they are stored in IndexedProperties enum (dense or sparse). Shapes only effect symbol and string properties.

My guess is that it's the layers of indirection, object -> shape -> PropertyTable, so doing a property lookup on length has more overhead (which #2767 addresses). and the pop method internally does a length property lookup too (which #2796 addresses)

EDIT:

Ran the benchmarks locally on main and #2796 branch and there was a ~20% increase in performance in Array Pop and a ~27% increase in Array Access.

@jasonwilliams
Copy link
Member

Ok thanks for looking, the rest of the PR looks fine to me, good job!

- Make forward reference weak gc
- Add shape property table cache
- Implement unique shape
- Implement unique shape property deleting delete
- Move property desciptor flags to shape
- Remove unneeded Option in property_table
- Implement shared property table
- Remove unneeded return of insert and remove
- Implement prototype transitions
- Implement varying width property storage
- Convert shape to unique if shape has exceeded transition max
- Add documentation
- Add `shape.md` documentation
- Use FxHashMap for lookup and vec for keys
- Direct initialization of arrays and objects with shape
- Make functions share the same shape
- Apply shared shapes to builtins
- Add forward reference check for attribute change
- Direct initialization of arrays
- Remove overwritten length property on TypedArray
- Refactor templates into separate struct
- Apply shapes to callable builtins
- Initialize builtin constructors directly
- Add inline caching to constructor function result
@github-actions
Copy link

Benchmark for 29ecc0f

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 566.8±1.23ns 628.7±668.50ns +10.92%
Arithmetic operations (Execution) 464.2±1.15ns 467.6±1.54ns +0.73%
Arithmetic operations (Parser) 7.8±0.14µs 7.5±0.01µs -3.85%
Array access (Compiler) 1742.5±7.84ns 1853.4±2074.10ns +6.36%
Array access (Execution) 7.5±0.02µs 7.1±5.38µs -5.33%
Array access (Parser) 14.7±0.09µs 14.9±0.02µs +1.36%
Array creation (Compiler) 2.5±0.02µs 2.8±2.79µs +12.00%
Array creation (Execution) 715.0±5.08µs 819.5±316.85µs +14.62%
Array creation (Parser) 18.2±0.05µs 17.6±0.05µs -3.30%
Array pop (Compiler) 4.2±0.01µs 5.8±8.17µs +38.10%
Array pop (Execution) 616.3±0.92µs 702.3±2.72µs +13.95%
Array pop (Parser) 171.6±6.46µs 162.6±0.11µs -5.24%
Boolean Object Access (Compiler) 1205.9±25.75ns 1216.2±1203.54ns +0.85%
Boolean Object Access (Execution) 5.5±0.01µs 5.8±4.17µs +5.45%
Boolean Object Access (Parser) 16.6±0.34µs 16.6±0.35µs 0.00%
Clean js (Compiler) 5.2±0.02µs 6.6±10.74µs +26.92%
Clean js (Execution) 803.7±2.19µs 878.7±398.26µs +9.33%
Clean js (Parser) 38.1±0.22µs 37.5±0.09µs -1.57%
Create Realm 507.4±2.15µs 521.1±1356.02µs +2.70%
Dynamic Object Property Access (Compiler) 2.1±0.01µs 2.4±2.82µs +14.29%
Dynamic Object Property Access (Execution) 4.8±0.01µs 4.4±7.46µs -8.33%
Dynamic Object Property Access (Parser) 13.1±0.06µs 13.2±0.05µs +0.76%
Fibonacci (Compiler) 3.1±0.00µs 5.3±17.87µs +70.97%
Fibonacci (Execution) 1158.3±3.53µs 884.4±680.78µs -23.65%
Fibonacci (Parser) 22.0±0.22µs 20.6±0.09µs -6.36%
For loop (Compiler) 2.8±0.00µs 3.2±2.74µs +14.29%
For loop (Execution) 17.9±0.02µs 18.3±19.94µs +2.23%
For loop (Parser) 20.5±0.11µs 18.7±0.05µs -8.78%
Mini js (Compiler) 4.5±0.01µs 5.9±8.53µs +31.11%
Mini js (Execution) 762.5±5.07µs 793.5±2.57µs +4.07%
Mini js (Parser) 34.1±0.43µs 33.0±0.07µs -3.23%
Number Object Access (Compiler) 1118.4±1.91ns 1157.3±924.51ns +3.48%
Number Object Access (Execution) 4.3±0.02µs 4.2±2.87µs -2.33%
Number Object Access (Parser) 13.1±0.19µs 13.2±0.04µs +0.76%
Object Creation (Compiler) 1832.1±13.83ns 1986.6±2273.04ns +8.43%
Object Creation (Execution) 4.6±0.01µs 3.9±5.05µs -15.22%
Object Creation (Parser) 11.5±0.10µs 11.4±0.03µs -0.87%
RegExp (Compiler) 2.1±0.01µs 2.2±2.32µs +4.76%
RegExp (Execution) 12.6±0.03µs 11.9±5.98µs -5.56%
RegExp (Parser) 12.6±0.14µs 12.3±0.02µs -2.38%
RegExp Creation (Compiler) 1829.6±9.61ns 5.9±38.75µs +222.47%
RegExp Creation (Execution) 9.1±0.04µs 8.6±6.16µs -5.49%
RegExp Creation (Parser) 10.6±0.49µs 10.4±0.05µs -1.89%
RegExp Literal (Compiler) 2.1±0.09µs 2.4±3.71µs +14.29%
RegExp Literal (Execution) 12.7±0.03µs 12.2±6.76µs -3.94%
RegExp Literal (Parser) 13.7±0.05µs 13.6±0.04µs -0.73%
RegExp Literal Creation (Compiler) 1844.6±7.35ns 2.1±2.71µs +13.85%
RegExp Literal Creation (Execution) 9.0±0.01µs 8.7±7.58µs -3.33%
RegExp Literal Creation (Parser) 11.5±0.03µs 11.6±0.04µs +0.87%
Static Object Property Access (Compiler) 1828.7±6.47ns 1872.3±2098.54ns +2.38%
Static Object Property Access (Execution) 4.7±0.02µs 4.1±4.67µs -12.77%
Static Object Property Access (Parser) 12.1±0.08µs 12.1±0.04µs 0.00%
String Object Access (Compiler) 1571.3±13.33ns 1682.2±1855.94ns +7.06%
String Object Access (Execution) 7.1±0.02µs 7.4±7.39µs +4.23%
String Object Access (Parser) 16.6±0.27µs 16.6±0.45µs 0.00%
String comparison (Compiler) 2.7±0.01µs 3.2±4.86µs +18.52%
String comparison (Execution) 4.4±0.01µs 3.1±3.11µs -29.55%
String comparison (Parser) 15.2±0.18µs 14.9±0.07µs -1.97%
String concatenation (Compiler) 2.1±0.01µs 2.8±5.92µs +33.33%
String concatenation (Execution) 4.1±0.02µs 3.1±4.04µs -24.39%
String concatenation (Parser) 10.2±0.08µs 10.2±0.09µs 0.00%
String copy (Compiler) 1729.9±11.56ns 2.2±2.92µs +27.17%
String copy (Execution) 3.8±0.01µs 2.9±4.02µs -23.68%
String copy (Parser) 7.7±0.07µs 7.8±0.04µs +1.30%
Symbols (Compiler) 1246.1±6.56ns 1357.9±1582.98ns +8.97%
Symbols (Execution) 3.9±0.01µs 2.9±3.96µs -25.64%
Symbols (Parser) 6.0±0.04µs 5.7±0.01µs -5.00%

@Razican
Copy link
Member

Razican commented Apr 26, 2023

The part that I reviewed looked great. Amazing work!!

bors r+

bors bot pushed a commit that referenced this pull request Apr 26, 2023
This PR implements `Hidden Classes`, I named them as `Shapes` (like Spidermonkey does), calling them maps like v8 seems confusing because there already is a JS builtin, likewise with `Hidden classes` since there are already classes in JS.

There are two types of shapes:  `shared` shapes that create the transition tree, and are shared between objects, this is mainly intended for user defined objects this makes more sense because shapes can create transitions trees, doing that for the builtins seems wasteful (unless users wanted  to creating an object with the same property names and the same property attributes in the same order... which seems unlikely). That's why I added  `unique` shapes, only one object has it. This is similar to previous solution, but this architecture enables us to use inline caching.

There will probably be a performance hit until we implement inline caching.

There still a lot of work that needs to be done, on this:

- [x] Move Property Attributes to shape
- [x] Move Prototype to shape
- [x] ~~Move extensible flag  to shape~~,  On further evaluation this doesn't give any benefit (at least right now), since it isn't used by inline caching also adding one more transition.
- [x] Implement delete for unique shapes.
- [x] If the chain is too long we should probably convert it into a `unique` shape
    - [x] Figure out threshold ~~(maybe more that 256 properties ?)~~ curently set to an arbitrary number (`1024`)
- [x] Implement shared property table between shared shapes
- [x] Add  code Document
- [x] Varying size storage for  properties (get+set = 2, data = 1)
- [x] Add shapes to more object:
    - [x] ordinary object
    - [x] Arrays
    - [x] Functions
    - [x] Other builtins
- [x] Add `shapes.md` doc explaining shapes in depth with mermaid diagrams :)
- [x] Add `$boa.shape` module
- [x] `$boa.shape.id(o)`
- [x] `$boa.shape.type(o)`
- [x] `$boa.shape.same(o1, o2)`
- [x] add doc to `boa_object.md`
@bors
Copy link

bors bot commented Apr 26, 2023

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Implement Hidden classes [Merged by Bors] - Implement Hidden classes Apr 26, 2023
@bors bors bot closed this Apr 26, 2023
@bors bors bot deleted the optimization/object-shapes branch April 26, 2023 05:42
@HalidOdat HalidOdat linked an issue Apr 27, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
execution Issues or PRs related to code execution run-benchmark Label used to run banchmarks on PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Hidden Classes/Object Shapes
4 participants