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: Avoid repeated traversal when creating scope #16964

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented Nov 15, 2024

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This avoids multiple traversals when child nodes are modified and scopes are recreated.
I'm surprised this actually works all the time.🤦‍♂️

PS F:\babel\benchmark> node --expose-gc .\all\real-case-ts-mjs.mjs
all/real-case-ts-mjs.mjs babel-parser-express.ts @ current: 40.94 ops/sec ±2.98% 205 runs (24ms)
all/real-case-ts-mjs.mjs babel-parser-express.ts @ baseline: 40.57 ops/sec ±3.45% 203 runs (25ms)
all/real-case-ts-mjs.mjs ts-parser.ts @ current: 7.82 ops/sec ±4.09% 40 runs (128ms)
all/real-case-ts-mjs.mjs ts-parser.ts @ baseline: 6.73 ops/sec ±3.09% 34 runs (149ms)
PS F:\babel\benchmark> node --expose-gc .\all\real-case-mjs-cjs.mjs
all/real-case-mjs-cjs.mjs ts-checker.mjs @ current: 1.14 ops/sec ±3.77% 10 runs (878ms)
all/real-case-mjs-cjs.mjs ts-checker.mjs @ baseline: 1.11 ops/sec ±6.37% 10 runs (905ms)
all/real-case-mjs-cjs.mjs ts-parser.mjs @ current: 9.26 ops/sec ±3.99% 47 runs (108ms)
all/real-case-mjs-cjs.mjs ts-parser.mjs @ baseline: 9.15 ops/sec ±4.29% 46 runs (109ms)

@babel-bot
Copy link
Collaborator

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

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

Nice catch!

@liuxingbaoyu liuxingbaoyu added pkg: traverse (scope) PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels Nov 15, 2024
@JLHwung JLHwung merged commit 943bdfe into babel:main Nov 18, 2024
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: traverse (scope) 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.

4 participants