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
Improve performance by directly constructing AST from buffer #5391
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#ast-consume-buffer Notice: Ensure you have installed Rust nightly. If you haven't installed it yet, please first see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust, then see https://rust-lang.github.io/rustup/concepts/channels.html to learn how to install Rust nightly. or load it into the REPL: |
24ad0c5
to
364b667
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5391 +/- ##
==========================================
- Coverage 98.81% 98.80% -0.02%
==========================================
Files 232 236 +4
Lines 9019 9418 +399
Branches 2355 2396 +41
==========================================
+ Hits 8912 9305 +393
- Misses 46 48 +2
- Partials 61 65 +4 ☔ View full report in Codecov by Sentry. |
364b667
to
1201c01
Compare
This prepares for the new buffer parsing
TODO: Special logic in parseNode of some nodes
This should make future template logic easier
We still need to update generate-buffer-parsers with the provided changes.
The second run uses the cache
* Do not generate cache on CLI unless requested * Keep AST if cache is not explicitly disabled
This does not work on non-x86 architectures
2668e28
to
8f99a40
Compare
9ea01ac
to
16edcea
Compare
This PR has been released as part of rollup@4.12.0. You can test it via |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
At long last, this is the next step in improving Rollup's performance. Previously when parsing code, Rollup would first construct a JSON AST and then convert this into an internal AST structure. Now with this change, Rollup skips the JSON step and directly constructs the internal AST from the buffer.
One reason this took a while is also that I needed to figure out what to do
moduleParsed
/this.getModuleInfo
: We construct it lazily for now, just like whenthis.parse
is called.So how much do we gain? To that end, I completely rewrote the perf script included with Rollup. Now when you run
npm run perf
, it will basically rebuild the esbuild benchmark of bundling ThreeJS ten times but without plugins, i.e. no minification. This will then be run 5 times for the current build and 5 times for what is installed in node_modules, taking turns between the two to compensate for changes in machine utilization. The largest two results from both are dropped and the rest is averaged.Then we are running Rollup with the
perf
option to get detailed timings so that it is possible to see where changes come from. This is the result:So you can see
const bundle = rollup(inputOptions)
is reduced by 14%. This can be attributed to module graph generation, which has been reduced by 34% (the generate AST line is an artifact as I changed how it is measured, the old value was not helpful). This is a lot!