Skip to content

perf(ast): remove write! macro where unnecessary#10234

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-04-perf_ast_remove_write_macro_where_unnecessary
Apr 4, 2025
Merged

perf(ast): remove write! macro where unnecessary#10234
graphite-app[bot] merged 1 commit intomainfrom
04-04-perf_ast_remove_write_macro_where_unnecessary

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Apr 4, 2025

Same as #10230, but for oxc_ast crate.

Replace usages of write! macro with either fmt.write_str(...) for static strings or Display::fmt / Debug::fmt for other values, where it's not being used to concatenate multiple values.

Formatter::write_str is more performant, as it avoids various checks. Display::fmt / Debug::fmt may also perform a little better in some cases, and will be equivalent in others. But in all cases it should be better for compile times, due to avoiding macro expansion and trait resolution.

Also, avoid allocating temporary Strings in Display impl for ModuleExportName.

Copy link
Member Author

overlookmotel commented Apr 4, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added A-ast Area - AST C-performance Category - Solution not expected to change functional behavior, only performance labels Apr 4, 2025
@overlookmotel overlookmotel marked this pull request as ready for review April 4, 2025 14:55
@overlookmotel overlookmotel requested a review from Boshen April 4, 2025 15:00
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 4, 2025

CodSpeed Instrumentation Performance Report

Merging #10234 will improve performances by 6.19%

Comparing 04-04-perf_ast_remove_write_macro_where_unnecessary (5b4c2ae) with main (fa0e455)

Summary

⚡ 1 improvements
✅ 35 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
formatter[typescript.js] 7.6 ms 7.2 ms +6.19%

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Apr 4, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Apr 4, 2025

Merge activity

Same as #10230, but for `oxc_ast` crate.

Replace usages of `write!` macro with either `fmt.write_str(...)` for static strings or `Display::fmt` / `Debug::fmt` for other values, where it's not being used to concatenate multiple values.

`Formatter::write_str` is more performant, as it avoids various checks. `Display::fmt` / `Debug::fmt` may also perform a little better in some cases, and will be equivalent in others. But in all cases it should be better for compile times, due to avoiding macro expansion and trait resolution.

Also, avoid allocating temporary `String`s in `Display` impl for `ModuleExportName`.
@graphite-app graphite-app bot force-pushed the 04-04-perf_ast_remove_write_macro_where_unnecessary branch from 8c23206 to 5b4c2ae Compare April 4, 2025 15:45
@graphite-app graphite-app bot merged commit 5b4c2ae into main Apr 4, 2025
29 checks passed
@graphite-app graphite-app bot deleted the 04-04-perf_ast_remove_write_macro_where_unnecessary branch April 4, 2025 15:56
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant