Skip to content

perf: skip span hashing in non-incremental builds#159796

Draft
xmakro wants to merge 1 commit into
rust-lang:mainfrom
xmakro:perf/skip-span-hashing-nonincr
Draft

perf: skip span hashing in non-incremental builds#159796
xmakro wants to merge 1 commit into
rust-lang:mainfrom
xmakro:perf/skip-span-hashing-nonincr

Conversation

@xmakro

@xmakro xmakro commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Span stable-hashing only matters when the hashes outlive the session, i.e. for incremental fingerprints and coverage source hashes. This PR changes it to be off otherwise, which leads to ~2% fewer instructions on non-incr full builds.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Jul 23, 2026
@Kobzol

Kobzol commented Jul 24, 2026

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
perf: skip span hashing in non-incremental builds
@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: f2d657e (f2d657ea99c440e3e341998de02b54cba54d84bc)
Base parent: 1498f99 (1498f9968f75e8e5ded6892b9c97bfe66b5a966f)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (f2d657e): 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 rustc-perf
@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.2% [0.2%, 0.3%] 16
Improvements ✅
(primary)
-3.2% [-6.7%, -0.5%] 71
Improvements ✅
(secondary)
-2.9% [-10.3%, -0.3%] 105
All ❌✅ (primary) -3.2% [-6.7%, -0.5%] 71

Max RSS (memory usage)

Results (primary -2.4%, secondary -3.0%)

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)
2.1% [2.1%, 2.1%] 2
Improvements ✅
(primary)
-2.4% [-3.8%, -1.1%] 14
Improvements ✅
(secondary)
-3.3% [-6.3%, -1.6%] 46
All ❌✅ (primary) -2.4% [-3.8%, -1.1%] 14

Cycles

Results (primary -3.9%, secondary -4.5%)

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)
- - 0
Improvements ✅
(primary)
-3.9% [-7.1%, -2.0%] 31
Improvements ✅
(secondary)
-4.5% [-10.5%, -1.8%] 46
All ❌✅ (primary) -3.9% [-7.1%, -2.0%] 31

Binary size

Results (primary 0.0%, secondary 0.0%)

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

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

Bootstrap: 486.272s -> 487.245s (0.20%)
Artifact size: 387.67 MiB -> 388.11 MiB (0.11%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 24, 2026
// code moving around; otherwise skip them and their source map lookups.
// Spans are also skipped if `-Z incremental-ignore-spans` is set.
let hash_spans_initial = (sess.opts.incremental.is_some() || sess.instrument_coverage())
&& !sess.opts.unstable_opts.incremental_ignore_spans;

@bjorn3 bjorn3 Jul 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_stable_hashing_context is also used in the legacy symbol mangling, for type id hashes and most importantly the crate hash which should depend on all compiler inputs that could potentially affect the output, which includes spans.

View changes since the review

@xmakro
xmakro force-pushed the perf/skip-span-hashing-nonincr branch from 8ea1e4e to f38bdb4 Compare July 24, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants