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

Some minor parser performance improvements for ts #16461

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented May 1, 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

The performance improvement is only 1%-5%. :)

PS F:\babel\benchmark\babel-parser\real-case-ts> node .\bench.mjs
baseline 1 typescript parser.ts: 64.27 ops/sec ±1.36% (16ms)
current 1 typescript parser.ts: 66.94 ops/sec ±1.32% (15ms)
baseline 1 typescript parser.ts: 64.85 ops/sec ±1% (15ms)
current 1 typescript parser.ts: 67.24 ops/sec ±1.05% (15ms)
PS F:\babel\benchmark\babel-parser\real-case-ts> node .\bench.mjs
current 1 typescript parser.ts: 66.09 ops/sec ±1.45% (15ms)
baseline 1 typescript parser.ts: 63.51 ops/sec ±1.03% (16ms)
current 1 typescript parser.ts: 67.24 ops/sec ±0.82% (15ms)
baseline 1 typescript parser.ts: 64.26 ops/sec ±1.03% (16ms)

@liuxingbaoyu liuxingbaoyu added pkg: parser PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels May 1, 2024
@babel-bot
Copy link
Collaborator

babel-bot commented May 1, 2024

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

@liuxingbaoyu liuxingbaoyu marked this pull request as draft May 1, 2024 20:11
@@ -260,6 +260,7 @@ function createWorker(useWorker) {
return require("./babel-worker.cjs");
}
const worker = new JestWorker(require.resolve("./babel-worker.cjs"), {
enableWorkerThreads: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is 0.3s faster on my local machine. :)

Comment on lines +31 to +42
copyFileSync(
require.resolve("@babel-baseline/parser"),
"./parser-baseline.cjs"
);
copyFileSync(
"../../../packages/babel-parser/lib/index.js",
"./parser-current.cjs"
);

const baseline = require("./parser-baseline.cjs");
const current = require("./parser-current.cjs");
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to do this otherwise I would get unstable benchmarks for current and I don't understand why.
I suspect that might have something to do with it, but it's still weird. It shouldn't cause any effect.
image

@liuxingbaoyu liuxingbaoyu marked this pull request as ready for review May 1, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants