Skip to content

perf(traverse): use ArenaString instead CompactString to store UID name#10562

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name
Apr 27, 2025
Merged

perf(traverse): use ArenaString instead CompactString to store UID name#10562
graphite-app[bot] merged 1 commit intomainfrom
04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Apr 23, 2025

close: #10545

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-performance Category - Solution not expected to change functional behavior, only performance labels Apr 23, 2025
Copy link
Member Author

Dunqing commented Apr 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 Apr 23, 2025

CodSpeed Instrumentation Performance Report

Merging #10562 will improve performances by 6.3%

Comparing 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name (bdcbeb4) with main (f89aec6)

Summary

⚡ 2 improvements
✅ 34 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
transformer[antd.js] 49.8 ms 47.4 ms +4.97%
transformer[cal.com.tsx] 32.9 ms 31 ms +6.3%

@overlookmotel overlookmotel changed the title perf(traverse): use ArenaString instead CompactString to stote uid name perf(traverse): use ArenaString instead CompactString to store uid name Apr 23, 2025
@overlookmotel overlookmotel changed the title perf(traverse): use ArenaString instead CompactString to store uid name perf(traverse): use ArenaString instead CompactString to store UID name Apr 23, 2025
@overlookmotel
Copy link
Member

bench

Holy smokes!

@Dunqing Dunqing changed the base branch from main to graphite-base/10562 April 23, 2025 11:36
@Dunqing Dunqing force-pushed the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch from 1816734 to 4c5d257 Compare April 23, 2025 11:36
@Dunqing Dunqing changed the base branch from graphite-base/10562 to 04-23-refactor_allocator_return_alloc_str_rather_than_alloc_mut_str_in_allocator_alloc_str_method April 23, 2025 11:36
@Dunqing Dunqing force-pushed the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch from 2834574 to 57f40a3 Compare April 23, 2025 11:42
@graphite-app graphite-app bot changed the base branch from 04-23-refactor_allocator_return_alloc_str_rather_than_alloc_mut_str_in_allocator_alloc_str_method to graphite-base/10562 April 23, 2025 12:43
@graphite-app graphite-app bot force-pushed the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch from 57f40a3 to a51cf57 Compare April 23, 2025 12:50
@graphite-app graphite-app bot force-pushed the graphite-base/10562 branch from d7962e9 to fb829d9 Compare April 23, 2025 12:50
@graphite-app graphite-app bot changed the base branch from graphite-base/10562 to main April 23, 2025 12:50
@graphite-app graphite-app bot force-pushed the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch from a51cf57 to 4186a3a Compare April 23, 2025 12:50
@Dunqing Dunqing force-pushed the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch 2 times, most recently from 1631e65 to 180aea7 Compare April 25, 2025 02:29
@Dunqing Dunqing marked this pull request as ready for review April 25, 2025 02:50
@Dunqing Dunqing force-pushed the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch from 180aea7 to 1f6b2ac Compare April 25, 2025 02:52
@Dunqing
Copy link
Member Author

Dunqing commented Apr 25, 2025

I found another possible improvement. Since generating UID name has used ArenaString, we can add a generate_uid_name_arena_string method to take ArenaString rather than &str because we still have a few places that use CompactString or format!() to construct a temporary name to pass in the generate_uid_name method. If we have this method, then we can use ArenaString to construct and pass in to get a UID name without double allocation.

let name = match method.kind {
MethodDefinitionKind::Method => ident.name.as_str(),
MethodDefinitionKind::Get => &format!("get_{}", ident.name),
MethodDefinitionKind::Set => &format!("set_{}", ident.name),
MethodDefinitionKind::Constructor => unreachable!(),
};
let binding = ctx.generate_uid(
name,
ctx.current_block_scope_id(),
SymbolFlags::Function,
);

let name = match method.kind {
MethodDefinitionKind::Method => ident.name.as_str(),
MethodDefinitionKind::Get => &format!("get_{}", ident.name),
MethodDefinitionKind::Set => &format!("set_{}", ident.name),
MethodDefinitionKind::Constructor => unreachable!(),
};
let binding = ctx.generate_uid(
name,
ctx.current_block_scope_id(),
SymbolFlags::Function,
);

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Apr 27, 2025
Copy link
Member

Boshen commented Apr 27, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch from 1f6b2ac to bdcbeb4 Compare April 27, 2025 02:39
@graphite-app graphite-app bot merged commit bdcbeb4 into main Apr 27, 2025
30 checks passed
@graphite-app graphite-app bot deleted the 04-23-perf_traverse_use_arenastring_instead_compactstring_to_stote_uid_name branch April 27, 2025 02:47
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 27, 2025
graphite-app bot pushed a commit that referenced this pull request May 1, 2025
Follow-on after #10562. Pure refactor. Merge `get_unique_name_impl` into `get_unique_name`.
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-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TraverseScoping::generate_uid_name return Atom not CompactStr

3 participants