-
-
Notifications
You must be signed in to change notification settings - Fork 629
test(formatter): check performance #12438
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
base: main
Are you sure you want to change the base?
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
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 #12438 will improve performances by 22.84%Comparing Summary
Benchmarks breakdown
|
2874c76
to
d936024
Compare
cb7b1ff
to
f0af69e
Compare
f0af69e
to
94c912d
Compare
94c912d
to
d6761fd
Compare
Gains 13%-20% performance improvement by pre-reserving enough space 🤣 |
@@ -371,7 +371,7 @@ pub fn format<'ast>( | |||
arguments: Arguments<'_, 'ast>, | |||
) -> FormatResult<Formatted<'ast>> { | |||
let mut state = FormatState::new(program, context); | |||
let mut buffer = VecBuffer::with_capacity(arguments.items().len(), &mut state); | |||
let mut buffer = VecBuffer::with_capacity(program.source_text.len(), &mut state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way too big? Integrate will monitor-oxc andd see what the average is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the worst-case scenario where every character is an element. I will measure the average when I start fully working on improving performance. Now this is an experiment.
Not to rain on your parade, but... I fear CodSpeed may be lying to us. Aapo taught me some stuff: oxc-project/backlog#11 (comment) (see "Multiple pointers + cost of growth" section of that comment). From what he's saying, avoiding growing To be fair to CodSpeed, I've also contributed to the unrealism of our benchmarks. To reduce variance in the numbers, I added a custom global allocator which specifically disables I haven't had time to properly dig into all this, but just letting you know our benchmarks may be misleading in this respect. If you want to make sure this change has real-world effect, you could run benchmarks locally before/after this PR. BUT comment out the custom global allocator One other thing: The |
Thank you for letting me know this, which is totally new for me! I've run the benchmark in my local environment and commented out The result is still very promising! cargo bench --bench formatter -- -b main
warning: unused imports: `GlobalAlloc`, `Layout`, and `System`
--> tasks/benchmark/src/lib.rs:1:18
|
1 | use std::alloc::{GlobalAlloc, Layout, System};
| ^^^^^^^^^^^ ^^^^^^ ^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: `oxc_benchmark` (lib) generated 1 warning (run `cargo fix --lib -p oxc_benchmark` to apply 1 suggestion)
Finished `bench` profile [optimized] target(s) in 0.08s
Running benches/formatter.rs (target/release/deps/formatter-1c8db0825dd6469e)
formatter/RadixUIAdoptionSection.jsx
time: [16.466 µs 16.480 µs 16.494 µs]
change: [−12.063% −11.881% −11.703%] (p = 0.00 < 0.05)
Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
3 (3.00%) low mild
3 (3.00%) high mild
4 (4.00%) high severe
Benchmarking formatter/react.development.js: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 5.3s, enable flat sampling, or reduce sample count to 60.
formatter/react.development.js
time: [875.18 µs 877.19 µs 879.28 µs]
change: [−5.5710% −5.2475% −4.9185%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe
formatter/cal.com.tsx time: [13.719 ms 13.742 ms 13.765 ms]
change: [−17.482% −17.273% −17.070%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild
formatter/binder.ts time: [1.9549 ms 1.9570 ms 1.9591 ms]
change: [+0.9608% +1.1245% +1.2814%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) low mild
1 (1.00%) high mild I guess the
Cool. Let me try this. |
I give up on replacing std |
Thanks for testing it out. The results are somewhat odd. Why does Let me clarify one thing I said earlier, as I think I phrased it badly:
I meant:
So switching from
I don't know if that's any clearer?! |
Do some experiments in this PR to see how the performance goes