Skip to content

perf(codegen): avoid allocation in PrivateIdentifier gen when not mangling#17395

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/12-27-perf_codegen_avoid_allocation_in_privateidentifier_gen_when_not_mangling
Dec 28, 2025
Merged

perf(codegen): avoid allocation in PrivateIdentifier gen when not mangling#17395
graphite-app[bot] merged 1 commit intomainfrom
c/12-27-perf_codegen_avoid_allocation_in_privateidentifier_gen_when_not_mangling

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 27, 2025

we previously always called into_compact_str when not mangling. This is unneccessary as we can just print from the string slice.

Screenshot 2025-12-27 at 20 42 12

@github-actions github-actions bot added A-codegen Area - Code Generation C-performance Category - Solution not expected to change functional behavior, only performance labels Dec 27, 2025
Copy link
Contributor Author

camc314 commented Dec 27, 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.

@camc314 camc314 marked this pull request as ready for review December 27, 2025 20:36
Copilot AI review requested due to automatic review settings December 27, 2025 20:36
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 code generation for private identifiers by avoiding unnecessary string allocation in the non-mangling case. Previously, the code always called into_compact_str() to create a new CompactStr, even when no mangling was needed.

Key changes:

  • Refactored the PrivateIdentifier generation logic to conditionally handle mangled vs. non-mangled cases
  • In the non-mangling case, the code now directly prints from the string slice without creating a CompactStr
  • In the mangling case, the logic remains functionally equivalent with the same allocation behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 27, 2025

CodSpeed Performance Report

Merging #17395 will not alter performance

Comparing c/12-27-perf_codegen_avoid_allocation_in_privateidentifier_gen_when_not_mangling (834155b) with main (585ddf8)

Summary

✅ 42 untouched
⏩ 3 skipped1

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 force-pushed the c/12-27-perf_codegen_avoid_allocation_in_privateidentifier_gen_when_not_mangling branch from 00f9f8d to 834155b Compare December 27, 2025 21:41
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 28, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 28, 2025

Merge activity

…gling (#17395)

we previously always called `into_compact_str` when not mangling. This is unneccessary as we can just print from the string slice.

<img width="692" height="173" alt="Screenshot 2025-12-27 at 20 42 12" src="https://github.com/user-attachments/assets/30228700-ec47-4894-b73a-8117c7a02af3" />
@graphite-app graphite-app bot force-pushed the c/12-27-perf_codegen_avoid_allocation_in_privateidentifier_gen_when_not_mangling branch from 834155b to 510ec00 Compare December 28, 2025 05:00
@graphite-app graphite-app bot merged commit 510ec00 into main Dec 28, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/12-27-perf_codegen_avoid_allocation_in_privateidentifier_gen_when_not_mangling branch December 28, 2025 05:06
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation 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