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

Compress unused slows down with deeply nested conditions #6066

Closed
dgreif opened this issue Oct 6, 2022 · 3 comments · Fixed by #6069
Closed

Compress unused slows down with deeply nested conditions #6066

dgreif opened this issue Oct 6, 2022 · 3 comments · Fixed by #6069
Assignees
Labels
Milestone

Comments

@dgreif
Copy link

dgreif commented Oct 6, 2022

Describe the bug

I'm working on updating SWC (from 1.2.205 to 1.3.4) and noticed that the latest version is very slow when trying to compress deeply nested conditions. We are using peggy.js which can quickly generate some very deep nesting. As the nesting approaches a depth of ~20, compression seems to slow down exponentially, and is on the order of many seconds even for a relatively small file size.

I was able to recreate the issue with some very basic peggy files - see https://github.com/dgreif/peggy-swc

The "large" file is only 600 lines long, but has over 20 levels of nesting here. This file takes ~20 seconds to compress. If I set compress.unused = false, it is almost instant.

I believe this is a duplicate of #5470, but that issue was closed because they were unable to provide a reproduction. I believe they were also using peggy, though they did not explicitly say so. They were also using deno, but I'm using Node.js.

Input code

No response

Config

{
  "$schema": "https://json.schemastore.org/swcrc",
  "minify": true,
  "jsc": {
    "minify": {
      "compress": {
        "unused": true
      },
      "mangle": true
    }
  }
}

Playground link

No response

Expected behavior

SWC is blazing fast with all of our other code. I would expect it to handle deeply nested conditional statements with similar speed.

Actual behavior

No response

Version

1.3.4

Additional context

No response

@dgreif dgreif added the C-bug label Oct 6, 2022
@kdy1 kdy1 added this to the Planned milestone Oct 6, 2022
@kdy1 kdy1 self-assigned this Oct 6, 2022
@kdy1
Copy link
Member

kdy1 commented Oct 6, 2022

I think the new DCE is the cause, although bisecting is required to verify it

@kdy1
Copy link
Member

kdy1 commented Oct 6, 2022

image

Okay it was a correct guess

@kdy1 kdy1 closed this as completed in #6069 Oct 6, 2022
kdy1 added a commit that referenced this issue Oct 6, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.6 Oct 8, 2022
@swc-bot
Copy link
Collaborator

swc-bot commented Nov 7, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants