Skip to content

Only honor -Zincremental-verify-ich for incremental compiles - #159796

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

Only honor -Zincremental-verify-ich for incremental compiles#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

For non-incremental compiles the flag has no purpose. It triggers a query key verification sweep that costs ~1.3% of instructions on non-incr full measurements. This is overhead that exists only in the benchmark, not in real 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
Comment thread compiler/rustc_middle/src/ich.rs Outdated
// 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 Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I think get_symbol_hash and type_id_hash already hash with spans disabled, but I missed the crate hash which needs the spans. I'll follow #94878 (crate hash from the encoded metadata) first and might revisit this afterwards.

I reduced this PR now to just the -Zincremental-verify-ich change, which turned out to be a good part of the perf win, but is misleading because it is a perf artifact, see rust-lang/rustc-perf#2510

@xmakro
xmakro force-pushed the perf/skip-span-hashing-nonincr branch from 8ea1e4e to f38bdb4 Compare July 24, 2026 13:20
@xmakro xmakro changed the title perf: skip span hashing in non-incremental builds Only honor -Zincremental-verify-ich for incremental compiles Jul 25, 2026
@xmakro
xmakro force-pushed the perf/skip-span-hashing-nonincr branch from f38bdb4 to 50822b9 Compare July 25, 2026 20:35
@xmakro xmakro changed the title Only honor -Zincremental-verify-ich for incremental compiles Only pass -Zincremental-verify-ich for incremental compiles Jul 25, 2026
@xmakro
xmakro force-pushed the perf/skip-span-hashing-nonincr branch from 50822b9 to a142fcf Compare July 25, 2026 20:45
@xmakro xmakro changed the title Only pass -Zincremental-verify-ich for incremental compiles Only honor -Zincremental-verify-ich for incremental compiles Jul 25, 2026
@xmakro
xmakro force-pushed the perf/skip-span-hashing-nonincr branch from a142fcf to 44f0297 Compare July 25, 2026 20:50
@xmakro
xmakro force-pushed the perf/skip-span-hashing-nonincr branch from 44f0297 to b4df581 Compare July 27, 2026 14:26
@xmakro
xmakro force-pushed the perf/skip-span-hashing-nonincr branch from b4df581 to 6d48454 Compare July 27, 2026 14:39
@xmakro

xmakro commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

r? @Zalathar

@rustbot

rustbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Zalathar is not on the review rotation at the moment.
They may take a while to respond.

@xmakro
xmakro marked this pull request as ready for review July 27, 2026 19:31
@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 Jul 27, 2026
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-review Status: Awaiting review from the assignee but also interested parties. 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