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

Add SkipLocalsInit attribute #339

Merged
merged 1 commit into from
Sep 23, 2022
Merged

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Sep 23, 2022

For a very recursive parser what Esprima is, we can reduce overhead by using [SkipLocalsInit]. Performance is better and if test suite is happy, we should be happy.

Some information for reference: https://www.meziantou.net/csharp-9-improve-performance-using-skiplocalsinit.htm

Esprima.Benchmark.FileParsingBenchmark

Diff Method FileName Mean Error Gen 0 Gen 1 Allocated
Old ParseProgram angular-1.2.5 8.846 ms 0.0354 ms 250.0000 109.3750 4,315 KB
New 8,699.4 μs (-4%) 45.02 μs 250.0000 (0%) 109.3750 (0%) 4,315 KB (0%)
Old ParseProgram backbone-1.1.0 1.212 ms 0.0057 ms 41.0156 19.5313 676 KB
New 1,168.8 μs (-6%) 4.02 μs 41.0156 (0%) 19.5313 (0%) 676 KB (0%)
Old ParseProgram jquery-1.9.1 6.884 ms 0.0225 ms 226.5625 78.1250 3,764 KB
New 6,931.9 μs (-2%) 36.96 μs 226.5625 (0%) 78.1250 (0%) 3,764 KB (0%)
Old ParseProgram jquery.mobile-1.4.2 10.639 ms 0.0467 ms 343.7500 171.8750 5,798 KB
New 10,616.6 μs (-3%) 73.30 μs 343.7500 (0%) 171.8750 (0%) 5,798 KB (0%)
Old ParseProgram mootools-1.4.5 5.586 ms 0.0434 ms 187.5000 78.1250 3,091 KB
New 5,562.2 μs (-3%) 33.97 μs 187.5000 (0%) 78.1250 (0%) 3,091 KB (0%)
Old ParseProgram underscore-1.5.2 1.022 ms 0.0062 ms 33.2031 13.6719 571 KB
New 994.6 μs (-5%) 4.19 μs 33.2031 (0%) 13.6719 (0%) 571 KB (0%)
Old ParseProgram yui-3.12.0 4.965 ms 0.0320 ms 171.8750 70.3125 2,856 KB
New 5,070.9 μs (0%) 26.22 μs 171.8750 (0%) 70.3125 (0%) 2,856 KB (0%)

@lahma lahma merged commit f9e7b0b into sebastienros:main Sep 23, 2022
@lahma lahma deleted the skip-locals-init branch September 23, 2022 17:15
@adams85
Copy link
Collaborator

adams85 commented Sep 23, 2022

4-5% perf. gain for adding an attribute. What a catch! 👍

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