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 recursion performance v1 #1269

Merged
merged 5 commits into from Aug 26, 2022

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Aug 26, 2022

Just shuffling code around a bit, making sure less allocations and methods inline better.

releates to #1159

Esprima.Benchmark.SunSpiderBenchmark

Diff Method FileName Mean Error Gen 0 Gen 1 Gen 2 Allocated
Old Run 3d-cube 238.03 ms 0.346 ms 3000.0000 333.3333 - 51,129 KB
New 246.55 ms (+4%) 0.586 ms 3000.0000 (0%) 333.3333 (0%) - 51,129 KB (0%)
Old Run 3d-morph 187.54 ms 2.607 ms 3000.0000 1000.0000 333.3333 49,744 KB
New 195.80 ms (+4%) 0.391 ms 3000.0000 (0%) 1000.0000 (0%) 333.3333 (0%) 49,744 KB (0%)
Old Run 3d-raytrace 199.38 ms 0.295 ms 5000.0000 1000.0000 - 93,394 KB
New 199.12 ms (0%) 0.411 ms 5000.0000 (0%) 1000.0000 (0%) - 93,394 KB (0%)
Old Run access-binary-trees 101.04 ms 0.218 ms 4000.0000 1000.0000 - 78,472 KB
New 98.04 ms (-3%) 0.234 ms 4000.0000 (0%) 1000.0000 (0%) - 78,472 KB (0%)
Old Run access-fannkuch 567.70 ms 2.910 ms - - - 137 KB
New 566.12 ms (0%) 2.374 ms - - - 137 KB (0%)
Old Run access-nbody 229.46 ms 0.665 ms 3666.6667 333.3333 - 63,851 KB
New 230.65 ms (+1%) 0.759 ms 3000.0000 (-18%) - - 63,855 KB (0%)
Old Run access-nsieve 187.33 ms 0.483 ms 1000.0000 - - 21,519 KB
New 190.47 ms (+2%) 0.382 ms 1000.0000 (0%) - - 21,519 KB (0%)
Old Run bitop(...)-byte [24] 197.77 ms 1.416 ms 4000.0000 - - 68,950 KB
New 195.32 ms (-1%) 0.485 ms 4000.0000 (0%) - - 68,950 KB (0%)
Old Run bitops-bits-in-byte 307.26 ms 0.754 ms 2500.0000 - - 45,446 KB
New 311.24 ms (+1%) 0.764 ms 2500.0000 (0%) - - 45,446 KB (0%)
Old Run bitops-bitwise-and 212.56 ms 2.164 ms 5000.0000 - - 93,439 KB
New 191.41 ms (-10%) 0.633 ms 5000.0000 (0%) - - 93,439 KB (0%)
Old Run bitops-nsieve-bits 240.73 ms 1.248 ms 3000.0000 1000.0000 - 54,856 KB
New 247.91 ms (+3%) 1.652 ms 3000.0000 (0%) 1000.0000 (0%) - 54,856 KB (0%)
Old Run contr(...)rsive [21] 145.45 ms 0.291 ms 7000.0000 2000.0000 - 124,118 KB
New 143.34 ms (-1%) 0.332 ms 7500.0000 (+7%) 1750.0000 (-13%) - 124,118 KB (0%)
Old Run crypto-aes 158.69 ms 0.208 ms - - - 15,560 KB
New 156.52 ms (-1%) 0.708 ms - - - 15,611 KB (0%)
Old Run crypto-md5 126.05 ms 0.388 ms 5000.0000 1000.0000 - 95,416 KB
New 126.28 ms (0%) 0.914 ms 5000.0000 (0%) 1000.0000 (0%) - 95,416 KB (0%)
Old Run crypto-sha1 129.33 ms 0.433 ms 5000.0000 1000.0000 - 82,075 KB
New 126.92 ms (-2%) 0.280 ms 5000.0000 (0%) 1000.0000 (0%) - 82,075 KB (0%)
Old Run date-format-tofte 122.40 ms 0.303 ms 2000.0000 - - 48,636 KB
New 121.71 ms (-1%) 0.329 ms 2000.0000 (0%) - - 48,636 KB (0%)
Old Run date-format-xparb 67.91 ms 0.233 ms 1750.0000 750.0000 - 29,417 KB
New 64.83 ms (-5%) 0.073 ms 1750.0000 (0%) 750.0000 (0%) - 29,415 KB (0%)
Old Run math-cordic 426.56 ms 1.130 ms 7000.0000 - - 123,974 KB
New 425.90 ms (0%) 1.255 ms 7000.0000 (0%) - - 123,974 KB (0%)
Old Run math-partial-sums 155.27 ms 2.959 ms 4000.0000 - - 68,947 KB
New 152.96 ms (-1%) 0.194 ms 4000.0000 (0%) - - 68,947 KB (0%)
Old Run math-spectral-norm 162.92 ms 0.704 ms 4000.0000 - - 67,176 KB
New 154.90 ms (-5%) 0.349 ms 4000.0000 (0%) - - 67,176 KB (0%)
Old Run regexp-dna 107.95 ms 0.482 ms 1000.0000 1000.0000 1000.0000 17,671 KB
New 107.46 ms (0%) 0.440 ms 800.0000 (-20%) 800.0000 (-20%) 800.0000 (-20%) 17,668 KB (0%)
Old Run string-base64 123.15 ms 1.415 ms - - - 12,528 KB
New 123.01 ms (0%) 0.390 ms - - - 12,527 KB (0%)
Old Run string-fasta 230.79 ms 0.888 ms 10000.0000 333.3333 - 167,276 KB
New 225.28 ms (-2%) 0.349 ms 10000.0000 (0%) 333.3333 (0%) - 167,276 KB (0%)
Old Run string-tagcloud 82.99 ms 0.394 ms 2000.0000 1000.0000 - 48,438 KB
New 81.60 ms (-2%) 0.330 ms 2000.0000 (0%) 1000.0000 (0%) - 48,438 KB (0%)
Old Run string-unpack-code 82.17 ms 0.129 ms 5000.0000 571.4286 - 84,573 KB
New 82.40 ms (0%) 0.208 ms 5000.0000 (0%) 571.4286 (0%) - 84,574 KB (0%)
Old Run strin(...)input [21] 1,237.00 ms 24.321 ms 731000.0000 727000.0000 726000.0000 6,352,035 KB
New 1,244.22 ms (+1%) 32.819 ms 697000.0000 (-5%) 693000.0000 (-5%) 692000.0000 (-5%) 6,352,253 KB (0%)

@lahma lahma enabled auto-merge (squash) August 26, 2022 17:19
@lahma lahma merged commit 3020dff into sebastienros:main Aug 26, 2022
@lahma lahma deleted the call-stack-improvements branch August 26, 2022 17:21

public JintIfStatement(IfStatement statement) : base(statement)
{
}

protected override void Initialize(EvaluationContext context)
{
_statementConsequent = Build(_statement.Consequent);
_statementConsequent = new ProbablyBlockStatement(_statement.Consequent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to initialize everything upfront, even if it is not needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialize happens lazily, in this case not sure about perf benefit to delay more.

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