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

perf(es/minifier): Merge dead_branch_remover into pure optimizer #10201

Merged
merged 8 commits into from
Mar 20, 2025

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Mar 15, 2025

Description:

Merge dead_branch_remover into the pure optimizer to make sequential process parallel and reduce the overhead of the visitor pattern.

Related issue:

Copy link

changeset-bot bot commented Mar 15, 2025

🦋 Changeset detected

Latest commit: b02ff3d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member Author

kdy1 commented Mar 15, 2025

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

Copy link

codspeed-hq bot commented Mar 15, 2025

CodSpeed Performance Report

Merging #10201 will improve performances by 2.18%

Comparing kdy1/dead-code (b02ff3d) with main (b192dc8)

Summary

⚡ 8 improvements
✅ 144 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
serialization of serde 2.8 µs 2.8 µs +1.06%
es/minifier/libs/antd 2.7 s 2.6 s +2.04%
es/minifier/libs/echarts 1.9 s 1.8 s +2.18%
es/minifier/libs/jquery 122.3 ms 121 ms +1.02%
es/minifier/libs/lodash 142.3 ms 140.9 ms +1.01%
es/minifier/libs/three 779.2 ms 764 ms +1.98%
es/minifier/libs/typescript 4.6 s 4.5 s +2.16%
es/minifier/libs/victory 1.1 s 1.1 s +2.18%

@kdy1 kdy1 force-pushed the kdy1/min-to-pure branch from 390dbde to 2be5110 Compare March 17, 2025 02:41
@kdy1 kdy1 force-pushed the kdy1/dead-code branch 2 times, most recently from f53f9f0 to e5ca81e Compare March 17, 2025 03:40
@kdy1 kdy1 changed the base branch from kdy1/min-to-pure to graphite-base/10201 March 17, 2025 03:47
@kdy1 kdy1 force-pushed the graphite-base/10201 branch from 980e2f4 to 97f2180 Compare March 17, 2025 03:48
@kdy1 kdy1 changed the base branch from graphite-base/10201 to main March 17, 2025 03:48
@kdy1 kdy1 force-pushed the kdy1/dead-code branch 2 times, most recently from 66c8d74 to 99d30b3 Compare March 17, 2025 05:48
@kdy1 kdy1 changed the base branch from main to graphite-base/10201 March 17, 2025 08:14
@kdy1 kdy1 changed the base branch from graphite-base/10201 to kdy1/fix-min-drop-number March 17, 2025 08:14
@kdy1 kdy1 force-pushed the kdy1/fix-min-drop-number branch from d958be4 to a650278 Compare March 17, 2025 08:26
@kdy1 kdy1 requested a review from Copilot March 18, 2025 23:58
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates the functionality of dead_branch_remover into the pure optimizer to enable parallel processing and reduce visitor pattern overhead. Key changes include updating test snapshot sizes, adjusting control flow constructs in various minified test files, and refactoring duration formatting in the output index file.

Reviewed Changes

Copilot reviewed 104 out of 105 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/swc/tests/libs-size.snapshot.md Minor numeric adjustments in file sizes for several JS files
.changeset/wild-berries-divide.md Adds a changeset to document version bumps and the perf related change
crates/swc/tests/tsc-references/*.minified.js Updates control flow labels and statement formatting in test references
crates/swc/tests/vercel/full/ms/1/output/index.ts Refactors helper function name and error handling in duration formatting
crates/swc/tests/tsc-references/parserindenter.2.minified.js Reformats nested if blocks for indentation handling
crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersAccessibility.2.minified.js Updates chain assignment order for object members
Files not reviewed (1)
  • crates/swc_ecma_minifier/scripts/test.sh: Language not supported
Comments suppressed due to low confidence (2)

crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersAccessibility.2.minified.js:4

  • The chain assignment for the second block appears truncated compared to the original version. Verify if the removal of assignments for e1 is intentional to maintain the intended behavior.
TargetIsPublic || (TargetIsPublic = {}), a = b, a = i, a = d, b = a = e, b = i, b = d, b = e, i = a, i = b, i = d, i = e, d = a, d = b, d = i, d = e, e = a, e = b, e = i, e = d, TargetIsPublic || (TargetIsPublic = {}), a1 = b1, a1 = i1, a1 = d1, b1 = a1 = e1, b1 = i1, b1 = d1, b1 = e1, i1 = a1, i1 = b1, i1 = d1, i1 = e1, d1 = a1, d1 = b1, d1 = i1;

crates/swc/tests/tsc-references/parser_continueTarget3.2.minified.js:2

  • Replacing 'for(;;)continue;' with 'for(;;);' removes the continue statement, which may alter the loop’s behavior. Please verify that this change is intentional.
for(;;);

@@ -1,2 +1,2 @@
var a = (()=>"expected")();
var a = (()=>true ? "expected" : "unexpected1")();
Copy link
Member Author

Choose a reason for hiding this comment

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

Requires merging expr_simplifier into the pure minifier

Copy link
Member Author

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

@swc-project/core-es Can you review only rust code? I'm checking test diffs

kodiakhq[bot]
kodiakhq bot previously approved these changes Mar 19, 2025
@kdy1 kdy1 changed the title perf(es/minifier): Remove dead_branch_remover call perf(es/minifier): Merge dead_branch_remover into pure optimizer Mar 20, 2025
Copy link
Member Author

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

I'll merge this, but feel free to left a review as I can invert PR afterwards.

@kdy1 kdy1 enabled auto-merge (squash) March 20, 2025 10:16
@kdy1 kdy1 disabled auto-merge March 20, 2025 10:19
@kdy1 kdy1 merged commit 6841523 into main Mar 20, 2025
168 checks passed
@kdy1 kdy1 deleted the kdy1/dead-code branch March 20, 2025 10:19
kdy1 added a commit that referenced this pull request Mar 20, 2025
kdy1 added a commit that referenced this pull request Mar 20, 2025
@kdy1 kdy1 modified the milestones: Planned, v1.11.12 Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Revisit all logic in dead_branch_remover
1 participant