Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented May 23, 2025

Replace usage of String with StringBuilder (introduced in #11257) in transformer.

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels May 23, 2025
@overlookmotel overlookmotel marked this pull request as ready for review May 23, 2025 22:25
@overlookmotel overlookmotel requested a review from Dunqing as a code owner May 23, 2025 22:25
Copy link
Member Author

overlookmotel commented May 23, 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.

@codspeed-hq
Copy link

codspeed-hq bot commented May 23, 2025

CodSpeed Instrumentation Performance Report

Merging #11260 will improve performances by 29.52%

Comparing 05-23-refactor_transformer_use_stringbuilder_instead_of_string_ (202ffd2) with 05-23-refactor_parser_use_stringbuilder_instead_of_string_ (02d3bb7)

Summary

⚡ 1 improvements
✅ 37 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
mangler[cal.com.tsx] 3.5 ms 2.7 ms +29.52%

@overlookmotel overlookmotel force-pushed the 05-23-refactor_transformer_use_stringbuilder_instead_of_string_ branch from c93fda2 to 6af0650 Compare May 23, 2025 22:33
@overlookmotel overlookmotel marked this pull request as draft May 23, 2025 22:33
@overlookmotel
Copy link
Member Author

overlookmotel commented May 23, 2025

Oh bollocks! It's a -1% perf hit. Probably because main usage is generating UIDs, where we only use StringBuilder::from_strs_array_in which doesn't utilize StringBuilder's advantages, but receives its downsides. Should probably add Atom::from_strs_array_in for this use case, where you don't need any intermediate structure at all (no String or StringBuilder).

@overlookmotel overlookmotel changed the base branch from 05-23-refactor_parser_use_stringbuilder_instead_of_string_ to graphite-base/11260 May 24, 2025 01:05
@overlookmotel overlookmotel force-pushed the 05-23-refactor_transformer_use_stringbuilder_instead_of_string_ branch from 6af0650 to 7f10c31 Compare May 24, 2025 01:23
@overlookmotel overlookmotel force-pushed the graphite-base/11260 branch from 447d22e to dc1afcb Compare May 24, 2025 01:23
@overlookmotel overlookmotel changed the base branch from graphite-base/11260 to 05-23-refactor_parser_use_stringbuilder_instead_of_string_ May 24, 2025 01:23
@overlookmotel overlookmotel marked this pull request as ready for review May 24, 2025 01:26
@overlookmotel
Copy link
Member Author

The perf drop is now gone thanks to #11261 (or maybe it was just noise in benchmarks, hard to know). I did find from Godbolt that Atom::from_strs_array_in is a couple of instructions shorter than Atom::from(StringBuilder::from_strs_array_in)).

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

graphite-app bot commented May 24, 2025

Merge activity

Replace usage of `String` with `StringBuilder` (introduced in #11257) in transformer.
graphite-app bot pushed a commit that referenced this pull request May 24, 2025
Add `Atom::from_strs_array_in` method, to complement `String::from_strs_array_in`. In many places we were using `String::from_strs_array_in` only as a means to get an `Atom`. Cut out the middleman!

This prepares the way for #11260, and getting rid of `String` entirely.
@graphite-app graphite-app bot force-pushed the 05-23-refactor_parser_use_stringbuilder_instead_of_string_ branch from dc1afcb to 02d3bb7 Compare May 24, 2025 02:34
@graphite-app graphite-app bot force-pushed the 05-23-refactor_transformer_use_stringbuilder_instead_of_string_ branch from 7f10c31 to 202ffd2 Compare May 24, 2025 02:34
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 24, 2025
Base automatically changed from 05-23-refactor_parser_use_stringbuilder_instead_of_string_ to main May 24, 2025 02:41
@graphite-app graphite-app bot merged commit 202ffd2 into main May 24, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 05-23-refactor_transformer_use_stringbuilder_instead_of_string_ branch May 24, 2025 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants