Skip to content

Streamline CrateMetadataRef construction in provide_one!.#155628

Open
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:CStore-from_tcx
Open

Streamline CrateMetadataRef construction in provide_one!.#155628
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:CStore-from_tcx

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

cstore.get_crate_data() creates a CrateMetadataRef, which is exactly what we need. The current code is very confused and does several unnecessary things: mapping the FreezeReadGuard and calling CStore::from_tcx a second time to construct a second CrateMetadataRef.

This is a small perf win.

r? @mu001999

`cstore.get_crate_data()` creates a `CrateMetadataRef`, which is exactly
what we need. The current code is very confused and does several
unnecessary things: mapping the `FreezeReadGuard` and calling
`CStore::from_tcx` a second time to construct a second
`CrateMetadataRef`.

This is a small perf win.
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 22, 2026
@nnethercote
Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 22, 2026
Streamline `CrateMetadataRef` construction in `provide_one!`.
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 22, 2026

☀️ Try build successful (CI)
Build commit: 58e1a01 (58e1a01ba68db8f3f8e788e25c2fa9a2b69e480e, parent: 9ec5d5f32e19d250c7fbeaa90978c79105b39dee)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (58e1a01): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-1.2%, -0.3%] 14
Improvements ✅
(secondary)
-0.7% [-1.3%, -0.2%] 28
All ❌✅ (primary) -0.5% [-1.2%, -0.3%] 14

Max RSS (memory usage)

Results (primary 2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.7% [2.7%, 2.7%] 1

Cycles

Results (secondary -9.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.5% [4.5%, 4.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-12.6% [-18.7%, -3.5%] 5
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.594s -> 490.743s (0.23%)
Artifact size: 394.45 MiB -> 394.43 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2026
@nnethercote nnethercote marked this pull request as ready for review April 22, 2026 05:44
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 22, 2026
@nnethercote
Copy link
Copy Markdown
Contributor Author

Perf results show small but clear perf wins, mostly for doc builds.

@mu001999
Copy link
Copy Markdown
Member

mu001999 commented Apr 22, 2026

Cool! @bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 22, 2026

📌 Commit cb3df68 has been approved by mu001999

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 22, 2026
@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Apr 22, 2026

r? @bjorn3

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 22, 2026

📌 Commit cb3df68 has been approved by bjorn3

It is now in the queue for this repository.

@rustbot rustbot assigned bjorn3 and unassigned mu001999 Apr 22, 2026
@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Apr 22, 2026

Somehow I didn't see your approval at all mu001999. Let me give credit back to you.

@bors r=mu001999

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 22, 2026

📌 Commit cb3df68 has been approved by mu001999

It is now in the queue for this repository.

@nnethercote
Copy link
Copy Markdown
Contributor Author

Three approvals so far! It's a popular PR 😄

@mu001999 mu001999 self-assigned this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants