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

Back parser state exportedIdentifiers by set #13406

Merged
merged 3 commits into from Jun 1, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented May 31, 2021

Q                       A
Fixed Issues? Parsing named exports costs O(n^2) time
License MIT

This PR changes the data structure of exportedIdentifiers to a set to avoid O(n^2) time when checking duplicate exports. This PR also moves exportedIdentifiers to the root state so it won't be cloned in state.clone.

Benchmark result:

Length-1 named exports
$ node --predictable ./many-named-export/1-length.bench.mjs

baseline 256 length-1 named export: 2060 ops/sec ±20.93% (0.485ms)
baseline 512 length-1 named export: 875 ops/sec ±1.16% (1.143ms)
baseline 1024 length-1 named export: 273 ops/sec ±1.3% (3.669ms)
baseline 2048 length-1 named export: 73.69 ops/sec ±2.17% (14ms)

current 256 length-1 named export: 2862 ops/sec ±34.06% (0.349ms)
current 512 length-1 named export: 1747 ops/sec ±1.39% (0.572ms)
current 1024 length-1 named export: 814 ops/sec ±0.63% (1.228ms)
current 2048 length-1 named export: 392 ops/sec ±0.45% (2.549ms)

@JLHwung JLHwung added pkg: parser PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels May 31, 2021
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 38ea497:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/46592/

@JLHwung JLHwung merged commit ae3f5d9 into babel:main Jun 1, 2021
@JLHwung JLHwung deleted the move-exported-identfiers-to-root-state branch June 1, 2021 11:17
@JLHwung JLHwung mentioned this pull request Jun 1, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants