Skip to content

perf(cfg, diagnostics, lexer, syntax, tasks): remove write! macro where unnecessary#10236

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

perf(cfg, diagnostics, lexer, syntax, tasks): remove write! macro where unnecessary#10236
graphite-app[bot] merged 1 commit intomainfrom
04-04-perf_cfg_diagnostics_lexer_syntax_tasks_remove_write_macro_where_unnecessary

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Apr 4, 2025

Same as #10230, for small changes to various crates.

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.

Copy link
Member Author


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-parser Area - Parser A-cfg Area - Control Flow Graph 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:59
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Apr 4, 2025
Copy link
Member

Boshen commented Apr 4, 2025

Merge activity

@overlookmotel overlookmotel requested a review from Boshen April 4, 2025 15:01
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 4, 2025

CodSpeed Instrumentation Performance Report

Merging #10236 will degrade performances by 3.7%

Comparing 04-04-perf_cfg_diagnostics_lexer_syntax_tasks_remove_write_macro_where_unnecessary (fa0e455) with main (774f6ba)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 34 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
formatter[antd.js] 7.6 ms 7.9 ms -3.7%
formatter[typescript.js] 7.4 ms 7.2 ms +3.22%

…here unnecessary (#10236)

Same as #10230, for small changes to various crates.

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.
@graphite-app graphite-app bot force-pushed the 04-04-perf_cfg_diagnostics_lexer_syntax_tasks_remove_write_macro_where_unnecessary branch from fc9c4c7 to fa0e455 Compare April 4, 2025 15:22
@graphite-app graphite-app bot merged commit fa0e455 into main Apr 4, 2025
30 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 4, 2025
@graphite-app graphite-app bot deleted the 04-04-perf_cfg_diagnostics_lexer_syntax_tasks_remove_write_macro_where_unnecessary branch April 4, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cfg Area - Control Flow Graph A-parser Area - Parser 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.

2 participants