Skip to content

Use LocalDefId as an index in metadata encoding - #163321

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
aerooneqq:local-def-index
Oct 8, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
aerooneqq:local-def-index

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

The goal of this PR to eliminate encoding of a raw DefIndex, instead we should encode something (LocalDefId) that certainly indicates that index belongs to the local crate. The implementation of DefIndex encoding should always panic to prevent accidental remappings of non-local DefIndexes in #162809.

So the plan is as follows:

  • Use LocalDefId as a writing index in tables for metadata encoding, use LocalDefId instead of DefIndex everywhere, specialize encode/decode methods to correctly process it,
  • Replace implementation of encode_def_index in EncodeContext with panic, so we never remap and encode def index,
  • Make tables' keys two-sided: we can read and write using different index types, in this case we will write using LocalDefId and read using DefIndex (done in Allow using different index types when reading and writing to tables #163447).

Blocked by #162900.

r? @petrochenkov

@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 Sep 25, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 25, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 25, 2026
Create `LocalDefIndex` for metadata encoding
@rust-bors

rust-bors Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 2fa5a47 (2fa5a472bd28122b86b69706e673d2b3704e5c27)
Base parent: 4e701dc (4e701dc6ba63a40c908a173df269a55e1fd6297e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (2fa5a47): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@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.8% [0.8%, 0.9%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -0.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)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.5%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary -1.6%, secondary 3.8%)

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)
3.8% [3.8%, 3.8%] 1
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.6% [-1.6%, -1.6%] 1

Binary size

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

Bootstrap: 488.984s -> 488.935s (-0.01%)
Artifact size: 406.31 MiB -> 406.32 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 25, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir_id/src/definitions.rs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…ata, r=petrochenkov

Allow using different index types when reading and writing to tables

Make tables of metadata two-sided: one can write with one index type and read with another, as long as both those types are indexes. That will be used in rust-lang#163321 when we will have `LocalDefIndex` or similar type.

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…ata, r=petrochenkov

Allow using different index types when reading and writing to tables

Make tables of metadata two-sided: one can write with one index type and read with another, as long as both those types are indexes. That will be used in rust-lang#163321 when we will have `LocalDefIndex` or similar type.

r? @petrochenkov
tgross35 added a commit to tgross35/rust that referenced this pull request Sep 29, 2026
…ata, r=petrochenkov

Allow using different index types when reading and writing to tables

Make tables of metadata two-sided: one can write with one index type and read with another, as long as both those types are indexes. That will be used in rust-lang#163321 when we will have `LocalDefIndex` or similar type.

r? @petrochenkov
tgross35 added a commit to tgross35/rust that referenced this pull request Sep 29, 2026
…ata, r=petrochenkov

Allow using different index types when reading and writing to tables

Make tables of metadata two-sided: one can write with one index type and read with another, as long as both those types are indexes. That will be used in rust-lang#163321 when we will have `LocalDefIndex` or similar type.

r? @petrochenkov
@rust-bors

This comment has been minimized.

@aerooneqq
aerooneqq force-pushed the local-def-index branch 2 times, most recently from d3319be to 68c2396 Compare September 29, 2026 10:11
@rustbot rustbot added the A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) label Sep 29, 2026
@rust-log-analyzer

This comment has been minimized.

@aerooneqq

Copy link
Copy Markdown
Contributor Author

After some experiments with LocalDefIndex and LocalDefId it seems that LocalDefId is a better option, so now waiting for #162900 to merge and after that this will be ready.

@aerooneqq aerooneqq changed the title Create LocalDefIndex for metadata encoding Use LocalDefId as an index in metadata encoding Sep 29, 2026
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🔨 3 commits were squashed into b92cb3e.

@rust-bors
rust-bors Bot force-pushed the local-def-index branch from a32d487 to b92cb3e Compare October 7, 2026 08:37
@aerooneqq

Copy link
Copy Markdown
Contributor Author

@bors r=oli-obk,petrochenkov

@rust-bors

rust-bors Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b92cb3e has been tentatively approved by oli-obk,petrochenkov

It will be put into the queue for this repository once PR CI succeeds.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
…nkov

Use `LocalDefId` as an index in metadata encoding



The goal of this PR to eliminate encoding of a raw `DefIndex`, instead we should encode something (`LocalDefId`) that certainly indicates that index belongs to the local crate. The implementation of `DefIndex` encoding should always panic to prevent accidental remappings of non-local `DefIndex`es in #162809. 

So the plan is as follows:

- Use `LocalDefId` as a writing index in tables for metadata encoding, use `LocalDefId` instead of `DefIndex` everywhere, specialize encode/decode methods to correctly process it,
- Replace implementation of `encode_def_index` in `EncodeContext` with panic, so we never remap and encode def index,
- Make tables' keys two-sided: we can read and write using different index types, in this case we will write using `LocalDefId` and read using `DefIndex` (done in #163447).

Blocked by #162900.

r? @petrochenkov
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job dist-aarch64-freebsd failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

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

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

💔 Test for fcbcce8 failed: CI. Failed job:

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors retry

@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 Oct 8, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 8, 2026
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: oli-obk,petrochenkov
Duration: 3h 15m 21s
Pushing 65efa19 to main...

@rust-bors
rust-bors Bot merged commit 65efa19 into rust-lang:main Oct 8, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing fc2324d (parent) -> 65efa19 (this PR)

Test differences

Show 6 test diffs

6 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 65efa194201c67ba29b7384255a534d61c2aa3cb --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. test-x86_64-msvc-ext2: 1h 1m -> 1h 50m (+81.2%)
  2. test-armhf-gnu: 1h 1m -> 1h 40m (+64.3%)
  3. test-x86_64-mingw-2: 1h 43m -> 2h 48m (+63.0%)
  4. test-x86_64-mingw-1: 1h 58m -> 3h 2m (+54.5%)
  5. test-x86_64-gnu-tools: 47m 53s -> 1h 10m (+48.1%)
  6. test-x86_64-gnu-miri: 1h 6m -> 1h 34m (+42.7%)
  7. dist-android: 22m 45s -> 32m 26s (+42.6%)
  8. dist-apple-various: 2h -> 2h 48m (+39.6%)
  9. test-i686-gnu-1: 2h 23m -> 1h 29m (-37.7%)
  10. test-x86_64-gnu-next-trait-solver-polonius: 1h 5m -> 41m 5s (-37.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (65efa19): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (secondary 2.6%)

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.6% [0.7%, 3.7%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.8%)

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.8% [2.7%, 3.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 484.956s -> 485.904s (0.20%)
Artifact size: 406.45 MiB -> 406.44 MiB (-0.00%)

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) merged-by-bors This PR was explicitly merged by bors. 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.

8 participants