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

(poc/RFC) perf(parser): record nodes, scopes, symbols, and references while parsing #4926

Conversation

DonIsaac
Copy link
Contributor

@DonIsaac DonIsaac commented Aug 15, 2024

Add Statistics to AstBuilder and record how many AST nodes, symbols, scopes, and references were encountered during parsing.

I know @overlookmotel is considering passing around &mut AstBuilder<'a> in the parser, so I'm putting this here for conversation. It has the following benefits:

  • AstBuilder stays Copy
  • No breaking API changes

And has the following downsides:

  • Uses a small amount of unsafe rust
  • StatisticsCell can cause a memory leak if not used properly
  • StatisticsCell implementation is somewhat esoteric

NOTE: tests are failing because it does not record quite the correct number of each statistic, yet the point of this PR remains.

Copy link

graphite-app bot commented Aug 15, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @DonIsaac and the rest of your teammates on Graphite Graphite

@github-actions github-actions bot added A-parser Area - Parser A-semantic Area - Semantic A-ast Area - AST A-transformer Area - Transformer / Transpiler A-ast-tools Area - AST tools labels Aug 15, 2024
@DonIsaac DonIsaac changed the title (poc) perf(parser): record nodes, scopes, symbols, and references while parsing (poc/RFC) perf(parser): record nodes, scopes, symbols, and references while parsing Aug 15, 2024
@DonIsaac DonIsaac force-pushed the don/08-15-_poc_perf_parser_record_nodes_scopes_symbols_and_references_while_parsing branch from d3c3eb1 to 1b3b2ad Compare August 15, 2024 22:24
Copy link

codspeed-hq bot commented Aug 15, 2024

CodSpeed Performance Report

Merging #4926 will degrade performances by 9.54%

Comparing don/08-15-_poc_perf_parser_record_nodes_scopes_symbols_and_references_while_parsing (1b3b2ad) with don/08-15-refactor_ast_make_astbuilder_non-exhaustive (1082b22)

Summary

❌ 5 regressions
✅ 24 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark don/08-15-refactor_ast_make_astbuilder_non-exhaustive don/08-15-_poc_perf_parser_record_nodes_scopes_symbols_and_references_while_parsing Change
parser[RadixUIAdoptionSection.jsx] 77.1 µs 81 µs -4.9%
semantic[RadixUIAdoptionSection.jsx] 99.8 µs 110.4 µs -9.54%
semantic[antd.js] 126.9 ms 131.7 ms -3.67%
semantic[cal.com.tsx] 46.7 ms 48.4 ms -3.38%
semantic[pdf.mjs] 20.8 ms 21.9 ms -4.78%

@Boshen Boshen changed the base branch from don/08-15-refactor_ast_make_astbuilder_non-exhaustive to graphite-base/4926 August 19, 2024 05:32
@Boshen Boshen closed this Aug 23, 2024
@Boshen Boshen deleted the don/08-15-_poc_perf_parser_record_nodes_scopes_symbols_and_references_while_parsing branch August 23, 2024 02:59
@overlookmotel
Copy link
Contributor

@DonIsaac I've not written up my conclusions on AST Node IDs yet. Will try to do that today. We may be able to use some of the stuff in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST A-ast-tools Area - AST tools A-parser Area - Parser A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants