8000 perf(transformer/using): inline `enter_statement` by overlookmotel · Pull Request #9680 · oxc-project/oxc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf(transformer/using): inline enter_statement #9680

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

Conversation

overlookmotel
Copy link
Contributor
@overlookmotel overlookmotel commented Mar 11, 2025

enter_statement is a hot path, and most Statements are not BlockStatements or SwitchStatements, so in most cases this method does nothing.

Optimize for the common "nothing to do here" case by moving as much logic as possible out of enter_statement, to make that function as small as possible, so it can be inlined. Mark it #[inline].

Hopefully now when a Statement is neither of the types this visitor is interested in, finding that out and exiting will just be a couple of quick checks, and won't incur the cost of a function call.

Copy link
Contributor Author
overlookmotel commented Mar 11, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

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

@overlookmotel overlookmotel marked this pull request as ready for review March 11, 2025 07:33
@overlookmotel overlookmotel requested a review from Dunqing as a code owner March 11, 2025 07:33
@overlookmotel overlookmotel requested review from camc314 and removed request for Dunqing March 11, 2025 07:33
Copy link
codspeed-hq bot commented Mar 11, 2025

CodSpeed Performance Report

Merging #9680 will create unknown performance changes

Comparing 03-11-perf_transformer_using_inline_enter_statement_ (d303ba9) with main (076d872)

Summary

🆕 39 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 parser_napi[RadixUIAdoptionSection.jsx] N/A 4.9 ms N/A
🆕 parser_napi[pdf.mjs] N/A 1.8 s N/A
🆕 parser_napi_raw[RadixUIAdoptionSection.jsx] N/A 1.3 ms N/A
🆕 parser_napi_raw[cal.com.tsx] N/A 699.4 ms N/A
🆕 parser_napi_raw[checker.ts] N/A 1.1 s N/A
🆕 parser_napi_raw[pdf.mjs] N/A 265.9 ms N/A
🆕 codegen[checker.ts] N/A 23.1 ms N/A
🆕 codegen_sourcemap[checker.ts] N/A 66.2 ms N/A
🆕 isolated-declarations[vue-id.ts] N/A 58.7 ms N/A
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 20.8 µs N/A
🆕 lexer[antd.js] N/A 24.1 ms N/A
🆕 lexer[cal.com.tsx] N/A 5.7 ms N/A
🆕 lexer[checker.ts] N/A 14.5 ms N/A
🆕 lexer[pdf.mjs] N/A 3.8 ms N/A
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.7 ms N/A
🆕 linter[cal.com.tsx] N/A 1.2 s N/A
🆕 linter[checker.ts] N/A 3 s N/A
🆕 mangler[antd.js] N/A 16.1 ms N/A
🆕 mangler[react.development.js] N/A 294.6 µs N/A
🆕 mangler[typescript.js] N/A 39.7 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@overlookmotel
Copy link
Contributor Author
bench

A small gain. I guess most of the cost of #9310 is iterating over statements, as we suspected.

@camc314 camc314 force-pushed the 03-11-test_transformer_using_failing_test_for_class_name branch from 24ebeb0 to e136646 Compare March 11, 2025 09:50
@camc314 camc314 force-pushed the 03-11-perf_transformer_using_inline_enter_statement_ branch from 6a7dcbd to f46312c Compare March 11, 2025 09:50
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Mar 11, 2025
Copy link
Member
Boshen commented Mar 11, 2025

Merge activity

  • Mar 11, 5:53 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 11, 6:08 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 11, 6:47 AM EDT: The Graphite merge queue removed this pull request due to downstack failures on PR #9675.
  • Mar 11, 8:02 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 11, 8:02 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 11, 8:43 AM EDT: A user merged this pull request with the Graphite merge queue.

@graphite-app graphite-app bot force-pushed the 03-11-test_transformer_using_failing_test_for_class_name branch from e136646 to 4cee555 Compare March 11, 2025 10:16
@graphite-app graphite-app bot force-pushed the 03-11-perf_transformer_using_inline_enter_statement_ branch from f46312c to 8b7d2ef Compare March 11, 2025 10:17
graphite-app bot pushed a commit that referenced this pull request Mar 11, 2025
`enter_statement` is a hot path, and most `Statement`s are not `BlockStatement`s or `SwitchStatement`s, so in most cases this method does nothing.

Optimize for the common "nothing to do here" case by moving as much logic as possible out of `enter_statement`, to make that function as small as possible, so it can be inlined. Mark it `#[inline]`.

Hopefully now when a `Statement` is neither of the types this visitor is interested in, finding that out and exiting will just be a couple of quick checks, and won't incur the cost of a function call.
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 11, 2025
graphite-app bot pushed a commit that referenced this pull request Mar 11, 2025
`enter_statement` is a hot path, and most `Statement`s are not `BlockStatement`s or `SwitchStatement`s, so in most cases this method does nothing.

Optimize for the common "nothing to do here" case by moving as much logic as possible out of `enter_statement`, to make that function as small as possible, so it can be inlined. Mark it `#[inline]`.

Hopefully now when a `Statement` is neither of the types this visitor is interested in, finding that out and exiting will just be a couple of quick checks, and won't incur the cost of a function call.
@graphite-app graphite-app bot force-pushed the 03-11-perf_transformer_using_inline_enter_statement_ branch from 8b7d2ef to 1b8c6b0 Compare March 11, 2025 10:44
@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Mar 11, 2025
`enter_statement` is a hot path, and most `Statement`s are not `BlockStatement`s or `SwitchStatement`s, so in most cases this method does nothing.

Optimize for the common "nothing to do here" case by moving as much logic as possible out of `enter_statement`, to make that function as small as possible, so it can be inlined. Mark it `#[inline]`.

Hopefully now when a `Statement` is neither of the types this visitor is interested in, finding that out and exiting will just be a couple of quick checks, and won't incur the cost of a function call.
@graphite-app graphite-app bot force-pushed the 03-11-test_transformer_using_failing_test_for_class_name branch from 76df73e to 4dc32db Compare March 11, 2025 12:14
@graphite-app graphite-app bot force-pushed the 03-11-perf_transformer_using_inline_enter_statement_ branch from 1b8c6b0 to d303ba9 Compare March 11, 2025 12:15
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 11, 2025
Base automatically changed from 03-11-test_transformer_using_failing_test_for_class_name to main March 11, 2025 12:39
@graphite-app graphite-app bot merged commit d303ba9 into main Mar 11, 2025
34 checks passed
@graphite-app graphite-app bot deleted the 03-11-perf_transformer_using_inline_enter_statement_ branch March 11, 2025 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transformer Area - Transformer / Transpiler C-performance Category - Solution not expected to change functional behavior, only performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0