perf(napi/parser): faster fixup of BigInts and RegExps#10820
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #10820 will degrade performances by 4.89%Comparing Summary
Benchmarks breakdown
|
|
Regression in |
Merge activity
|
#10791 fixed the performance of `oxc-parser` NPM package by removing the reviver from `JSON.parse` call. However, it replaced it with a complete traversal of the AST on JS side to locate `Literal` nodes and update them. Instead, generate a list of paths to `Literal` nodes needing fixing on Rust side in `ESTree` serializer. e.g. for this program: ```js 123n; foo(/xyz/); ``` the fix paths are: ```json [ ["body", 0, "expression"], ["body", 1, "expression", "arguments", 2] ] ``` Having the location of nodes which need updating reduces work on JS side, as no need to search the entire AST. Running `pnpm run bench` (in `napi/parser`) locally shows between 8% and 15% speed-up from this change.
2362045 to
33969ac
Compare
514f81f to
49a6f97
Compare
…on separate lines (#10869) #10820 changed how `BigInt`s and `RegExp`s are fixed in ESTree AST on JS side. It adds a list of fix paths to the end of the JSON. Add line breaks after the inserted header, and before the inserted footer. This will allow playground to easily trim off the header and footer and display the raw JSON instead of converting the AST Object back to JSON with `JSON.stringify`. oxc-project/playground#101

#10791 fixed the performance of
oxc-parserNPM package by removing the reviver fromJSON.parsecall. However, it replaced it with a complete traversal of the AST on JS side to locateLiteralnodes and update them.Instead, generate a list of paths to
Literalnodes needing fixing on Rust side inESTreeserializer.e.g. for this program:
the fix paths are:
[ ["body", 0, "expression"], ["body", 1, "expression", "arguments", 2] ]Having the location of nodes which need updating reduces work on JS side, as no need to search the entire AST.
Running
pnpm run bench(innapi/parser) locally shows between 8% and 15% speed-up from this change.