Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a u64 for the rmeta root position #118344

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Conversation

saethlin
Copy link
Member

Waffle noticed this in #117301 (comment)

We've upgraded the other file offsets to u64, and this one only costs 4 bytes per file. Also the way the truncation was being done before was extremely easy to miss, I sure missed it! It's not clear to me if not having this change effectively made the other upgrades from u32 to u64 ineffective, but we can have it now.

r? @WaffleLapkin

@rustbot rustbot added 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. labels Nov 27, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Nov 28, 2023

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

// to know the length
let mut bytes_before_version = [0u8; 13];
let mut bytes_before_version = [0u8; 17];
Copy link
Member

Choose a reason for hiding this comment

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

This breaks support for previous versions, right?

The server will generally match the compiler, but this might still happen with already-built projects.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I patched this up by passing more data out of the version match above?

Copy link
Member

@lnicola lnicola Nov 29, 2023

Choose a reason for hiding this comment

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

It probably doesn't matter too much, but I think you could leave that as a 17 bytes array, and only read into a prefix slice of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

That feels like too much brainpower for this code to me.

@WaffleLapkin
Copy link
Member

Hm, does this ever matter? I.e. should we maybe simply fix the cast and leave it as 32-bit offset?

@saethlin
Copy link
Member Author

saethlin commented Dec 10, 2023

The crate root is written at the end of an rmeta file. So regardless of what we do elsewhere, we only support rmeta files up to the size that this offset supports.

Unlike the other examples such as #103607 this needs two crates, because you need to write out an rmeta file that is more than 4 GB, then have another crate that tries to use it. include_bytes! a 2 GB file into a const then try to print that const's length from another crate, for example. (I think you're suggesting we do a panicky instead of truncating conversion here? If we did that the first build would ICE not the second)

So without this change, use cases #112934 and #111855 are only fixed if the large crate is not a dependency.

@WaffleLapkin
Copy link
Member

Thanks for the explanation (I assumed (based on nothing) that the root is at the start)

compiler/rustc_codegen_ssa/src/back/metadata.rs Outdated Show resolved Hide resolved
compiler/rustc_metadata/src/rmeta/decoder.rs Outdated Show resolved Hide resolved
Comment on lines 121 to 122
// Last supported version is:
// https://github.com/rust-lang/rust/commit/0696e79f2740ad89309269b460579e548a5cd632
Copy link
Member

Choose a reason for hiding this comment

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

I think this should point to your commit updating the format (yes it looks like we forgot to update it 2 times already).

Copy link
Member Author

@saethlin saethlin Dec 11, 2023

Choose a reason for hiding this comment

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

It's so outdated that when I saw this I wasn't sure if it's supposed to point at the oldest or the newest version that's supported. I can point this at the first commit in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's supposed to point at the newest, because

  1. Last

  2. This points to 6, but the oldest supported version is 5, so I don't think it could have been added as an oldest one

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 11, 2023
@rust-log-analyzer

This comment has been minimized.

Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
@WaffleLapkin
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 11, 2023

📌 Commit 79bdd24 has been approved by WaffleLapkin

It is now in the queue for this repository.

@bors bors 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 Dec 11, 2023
@bors
Copy link
Contributor

bors commented Dec 11, 2023

⌛ Testing commit 79bdd24 with merge 5701093...

@bors
Copy link
Contributor

bors commented Dec 11, 2023

☀️ Test successful - checks-actions
Approved by: WaffleLapkin
Pushing 5701093 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 11, 2023
@bors bors merged commit 5701093 into rust-lang:master Dec 11, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 11, 2023
@saethlin saethlin deleted the rmeta-header-pos branch December 11, 2023 19:50
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5701093): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
4.7% [2.3%, 7.2%] 2
Regressions ❌
(secondary)
1.5% [1.5%, 1.5%] 1
Improvements ✅
(primary)
-4.1% [-4.1%, -4.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.8% [-4.1%, 7.2%] 3

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Bootstrap: 672.509s -> 670.568s (-0.29%)
Artifact size: 314.21 MiB -> 314.19 MiB (-0.01%)

@bzEq bzEq mentioned this pull request Dec 13, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 18, 2023
…Lapkin

[AIX] Fix XCOFF metadata

rust-lang#118344  accidentally changed the way to get metadata from XCOFF file and broken our internal CI.

This PR reverts part of rust-lang#118344 .
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2023
Rollup merge of rust-lang#118905 - bzEq:revert-u64-on-xcoff, r=WaffleLapkin

[AIX] Fix XCOFF metadata

rust-lang#118344  accidentally changed the way to get metadata from XCOFF file and broken our internal CI.

This PR reverts part of rust-lang#118344 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

8 participants