Skip to content

perf(mangler): store slot indexes as u32s#13462

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-31-perf_mangler_store_slot_indexes_as_u32_s
Aug 31, 2025
Merged

perf(mangler): store slot indexes as u32s#13462
graphite-app[bot] merged 1 commit intomainfrom
08-31-perf_mangler_store_slot_indexes_as_u32_s

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 31, 2025

There cannot be more slots than symbols, and SymbolId is a u32, so there can't be more than u32::MAX symbols. Therefore we can store slot indexes as u32 too.

@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Aug 31, 2025
Copy link
Member Author

overlookmotel commented Aug 31, 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.

@overlookmotel overlookmotel marked this pull request as ready for review August 31, 2025 10:23
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 31, 2025
Copy link
Member

Boshen commented Aug 31, 2025

Merge activity

  • Aug 31, 10:25 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 31, 10:28 AM UTC: Boshen added this pull request to the Graphite merge queue.
  • Aug 31, 10:31 AM UTC: The Graphite merge queue couldn't merge this PR because it was in draft mode.
  • Aug 31, 10:32 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 31, 10:32 AM UTC: overlookmotel added this pull request to the Graphite merge queue.
  • Aug 31, 10:38 AM UTC: Merged by the Graphite merge queue.

@graphite-app graphite-app bot changed the base branch from 08-31-perf_mangler_do_not_sort_vec_if_empty to graphite-base/13462 August 31, 2025 10:25
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 31, 2025

CodSpeed Instrumentation Performance Report

Merging #13462 will improve performances by 6.46%

Comparing 08-31-perf_mangler_store_slot_indexes_as_u32_s (0d66399) with main (caf40c5)1

Summary

⚡ 3 improvements
✅ 34 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
mangler[binder.ts] 780.8 µs 733.4 µs +6.46%
mangler[cal.com.tsx] 2.9 ms 2.8 ms +3.65%
mangler[react.development.js] 272.3 µs 259.5 µs +4.96%

Footnotes

  1. No successful run was found on main (0d66399) during the generation of this report, so caf40c5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as draft August 31, 2025 10:29
@graphite-app graphite-app bot changed the base branch from graphite-base/13462 to main August 31, 2025 10:31
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 31, 2025
@overlookmotel overlookmotel marked this pull request as ready for review August 31, 2025 10:32
Copilot AI review requested due to automatic review settings August 31, 2025 10:32
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Aug 31, 2025
Copy link
Contributor

Copilot AI left a 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 PR optimizes the mangler's slot storage by changing the slot index type from usize to u32. The optimization is based on the fact that there cannot be more slots than symbols, and since SymbolId is already a u32, the slot indexes can safely use the same type without risk of overflow.

Key changes:

  • Changed Slot type alias from usize to u32
  • Added explicit type casts with clippy suppressions where needed
  • Moved sort_unstable() call to after empty check for minor optimization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

There cannot be more slots than symbols, and `SymbolId` is a `u32`, so there can't be more than `u32::MAX` symbols. Therefore we can store slot indexes as `u32` too.
@graphite-app graphite-app bot force-pushed the 08-31-perf_mangler_store_slot_indexes_as_u32_s branch from a5345cb to 0d66399 Compare August 31, 2025 10:33
@graphite-app graphite-app bot merged commit 0d66399 into main Aug 31, 2025
23 of 24 checks passed
@graphite-app graphite-app bot deleted the 08-31-perf_mangler_store_slot_indexes_as_u32_s branch August 31, 2025 10:38
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants