-
-
Notifications
You must be signed in to change notification settings - Fork 728
perf(formatter): reuse previous indent stack in FitsMeasurer
#15416
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(formatter): reuse previous indent stack in FitsMeasurer
#15416
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 Performance ReportMerging #15416 will not alter performanceComparing Summary
Footnotes
|
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.
Pull Request Overview
This pull request extends the resource cleanup mechanism in the formatter's FitsMeasurer to properly handle indent stack resources. The changes ensure that indent stacks are recycled and reused across fits measurements, preventing unnecessary allocations.
- Adds a
finishmethod toFitsIndentStackthat extracts both the indent stack and history stack vectors - Updates the
FitsMeasurer::finishmethod to properly clear and return both indent stacks to the printer state for reuse
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_formatter/src/formatter/printer/call_stack.rs | Implements finish method for FitsIndentStack to extract and return both indent vectors |
| crates/oxc_formatter/src/formatter/printer/mod.rs | Extends FitsMeasurer::finish to clear and recycle indent stacks back to printer state |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
leaysgur
left a comment
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.
Please merge after addressing Copilot suggestion( which seems valid?). 🙆🏻♂️
6084899 to
86f714d
Compare
Merge activity
|
As said in https://github.com/oxc-project/oxc/blob/60848996f81a4d9808a0b5788cc225f10e524971/crates/oxc_formatter/src/formatter/printer/mod.rs#L703-L708 These four stacks should be reused in each FitsMeasurer run to avoid reallocation, but `fits_indent_stack` and `fits_stack_tem_indent are lacking. <img width="1268" height="434" alt="image" src="https://github.com/user-attachments/assets/43aeb36e-4c34-4fc9-8786-c45e353386aa" />
86f714d to
29f35b2
Compare

As said in
oxc/crates/oxc_formatter/src/formatter/printer/mod.rs
Lines 703 to 708 in 6084899
These four stacks should be reused in each FitsMeasurer run to avoid reallocation, but
fits_indent_stackand `fits_stack_tem_indent are lacking.