Skip to content

perf(minifier): reduce allocations when processing if statements - #26666

Merged
Dunqing merged 7 commits into
oxc-project:mainfrom
armano2:perf/do-not-recreate-if-stmt
Sep 16, 2026
Merged

Dunqing merged 7 commits into
oxc-project:mainfrom
armano2:perf/do-not-recreate-if-stmt

Conversation

@armano2

@armano2 armano2 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor
  • introduce context function replace_statement_with for replacing stmts in place
  • try_minimize_if rewrite statements to new statements in place
  • update if stmt instead of recreating it in handle_if_statement

@armano2
armano2 requested a review from Dunqing as a code owner September 14, 2026 21:33
@codspeed

codspeed Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 19 skipped benchmarks1


Comparing armano2:perf/do-not-recreate-if-stmt (a27579c) with main (827fdbd)2

Open in CodSpeed

Footnotes

  1. 19 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (fba80b6) during the generation of this report, so 827fdbd was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@armano2
armano2 force-pushed the perf/do-not-recreate-if-stmt branch from 17ce2d9 to 88a6624 Compare September 14, 2026 21:39
@camc314 camc314 added the A-minifier Area - Minification, compression and name mangling, oxc_minifier / oxc_mangler label Sep 15, 2026
@armano2
armano2 force-pushed the perf/do-not-recreate-if-stmt branch from 88a6624 to a27579c Compare September 15, 2026 14:48
@armano2 armano2 changed the title perf(minifier): do not recreate if stmt when merging with following stmts perf(minifier): reduce allocations when minimizing if statements Sep 15, 2026
@armano2 armano2 changed the title perf(minifier): reduce allocations when minimizing if statements perf(minifier): reduce allocations when processing if statements Sep 15, 2026
Dunqing added a commit that referenced this pull request Sep 16, 2026
The Label PR workflow runs on `pull_request`, where `GITHUB_TOKEN` is
read-only for PRs from forks, so it skips them and external PRs need
area labels applied by hand (see #26666). `pull_request_target` would
fix that but was banned in #21566.

Trigger the labeler from `workflow_run` on `Check PR` instead. That
event runs the workflow file from the default branch with a writable
token and never checks out PR code. The PR number is resolved from the
run's head branch through the API because `workflow_run.pull_requests`
is empty for forks. `actions/labeler` reads `labeler.yml` at the
default-branch sha and the changed files from the pull request API, so
the PR only controls which paths it touches.

`workflow_run` only fires from the default branch, so this cannot be
exercised on the PR itself.
@Dunqing

Dunqing commented Sep 16, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-16T06:29:39.919534Z a27579c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

graphite-app Bot pushed a commit that referenced this pull request Sep 16, 2026
The Label PR workflow runs on `pull_request`, where the token is read-only for PRs from forks, so external PRs need area labels applied by hand (#26666 for example). `pull_request_target` was banned in #21566.

Trigger the labeler from `workflow_run` on `Check PR` instead. The workflow file comes from the default branch, no PR code is checked out, and `actions/labeler` reads `labeler.yml` and the changed files through the API. The PR number is looked up by head branch and sha because `workflow_run.pull_requests` is empty for forks.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: a27579cfc2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Dunqing Dunqing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice improvement!

@Dunqing
Dunqing merged commit 5f72954 into oxc-project:main Sep 16, 2026
46 checks passed
@armano2
armano2 deleted the perf/do-not-recreate-if-stmt branch September 16, 2026 10:17
graphite-app Bot pushed a commit that referenced this pull request Sep 18, 2026
The Label PR workflow runs on `pull_request`, where the token is read-only for PRs from forks, so external PRs need area labels applied by hand (#26666 for example). `pull_request_target` was banned in #21566.

Trigger the labeler from `workflow_run` on `Check PR` instead. The workflow file comes from the default branch, no PR code is checked out, and `actions/labeler` reads `labeler.yml` and the changed files through the API. The PR number is looked up by head branch and sha because `workflow_run.pull_requests` is empty for forks.
graphite-app Bot pushed a commit that referenced this pull request Sep 21, 2026
### 🚀 Features

- 1fac655 coverage: Support new TypeScript fixture layout (#26226) (camc314)

### 🐛 Bug Fixes

- cd7228f minifier: Add missing negation for boolean literal (#26847) (Armano)
- 32305e2 transformer: Skip enum reverse mappings for syntactic string initializers (#26724) (Dunqing)
- 7811f0a parser: Preserve reparsed `await` tokens (#26619) (camc314)
- 9220158 transformer: Skip recovered using loop patterns (#26722) (camc314)
- 3130405 parser: Recover await using object binding patterns (#26721) (camc314)
- 827fdbd parser: Reject invalid modifiers on import aliases (#26622) (camc314)

### ⚡ Performance

- 3f1e3aa minifier: Preallocate stmts vec size to avoid excesive reallocs (#26856) (Armano)
- bd3f69e semantic: Reuse identifier hashes in enum member lookups (#26773) (camc314)
- 5f72954 minifier: Reduce allocations when processing if statements (#26666) (Armano)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minification, compression and name mangling, oxc_minifier / oxc_mangler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants