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

miri: avoid making a full copy of all new allocations #125633

Merged
merged 1 commit into from
May 29, 2024

Conversation

RalfJung
Copy link
Member

Hopefully fixes rust-lang/miri#3637

r? @saethlin

@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 May 27, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 27, 2024

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@RalfJung RalfJung force-pushed the miri-no-copy branch 2 times, most recently from 5e03c8f to 14801af Compare May 27, 2024 21:32
Comment on lines +346 to +349
// The default implementation does a copy; CTFE machines have a more efficient implementation
// based on their particular choice for `Provenance`, `AllocExtra`, and `Bytes`.
let kind = Self::GLOBAL_KIND
.expect("if GLOBAL_KIND is None, adjust_global_allocation must be overwritten");
Copy link
Member

Choose a reason for hiding this comment

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

🤨 So the implementation that Miri needs is the default, and the const fn interpreter overrides with something simpler? Don't we usually do things the other way around?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, but the other way around does not work here and the const-eval interpreter impl is not well-typed in general, in relies on specific choices for the associated type. And meanwhile it seems nice that a default impl is possible.

Copy link
Member

Choose a reason for hiding this comment

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

I see. It's always ironic when we run into loose typing implementing Rust.

Copy link
Member Author

Choose a reason for hiding this comment

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

To me this is actually a sign of a pretty powerful type system -- in the const-eval implementation we of course know more about the concrete choice of types than in the general trait definition, and that lets us safely convert between types that are in general inequal, but are known to be equal in this concrete instance.

@saethlin
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented May 28, 2024

📌 Commit 8693064 has been approved by saethlin

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-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this pull request May 28, 2024
miri: avoid making a full copy of all new allocations

Hopefully fixes rust-lang/miri#3637

r? `@saethlin`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 29, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#124251 (Add an intrinsic for `ptr::metadata`)
 - rust-lang#124320 (Add `--print=check-cfg` to get the expected configs)
 - rust-lang#125226 (Make more of the test suite run on Mac Catalyst)
 - rust-lang#125381 (Silence some resolve errors when there have been glob import errors)
 - rust-lang#125633 (miri: avoid making a full copy of all new allocations)
 - rust-lang#125638 (Rewrite `lto-smoke`, `simple-rlib` and `mixing-deps` `run-make` tests in `rmake.rs` format)
 - rust-lang#125639 (Support `./x doc run-make-support --open`)
 - rust-lang#125664 (Tweak relations to no longer rely on `TypeTrace`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 29, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#124251 (Add an intrinsic for `ptr::metadata`)
 - rust-lang#124320 (Add `--print=check-cfg` to get the expected configs)
 - rust-lang#125226 (Make more of the test suite run on Mac Catalyst)
 - rust-lang#125381 (Silence some resolve errors when there have been glob import errors)
 - rust-lang#125633 (miri: avoid making a full copy of all new allocations)
 - rust-lang#125638 (Rewrite `lto-smoke`, `simple-rlib` and `mixing-deps` `run-make` tests in `rmake.rs` format)
 - rust-lang#125639 (Support `./x doc run-make-support --open`)
 - rust-lang#125664 (Tweak relations to no longer rely on `TypeTrace`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 305137d into rust-lang:master May 29, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 29, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 29, 2024
Rollup merge of rust-lang#125633 - RalfJung:miri-no-copy, r=saethlin

miri: avoid making a full copy of all new allocations

Hopefully fixes rust-lang/miri#3637

r? ``@saethlin``
bors added a commit to rust-lang/miri that referenced this pull request May 29, 2024
Add a benchmark for creating large uninit allocations

Extracted from #3637

I used this program to confirm that rust-lang/rust#125633 has the desired effect.
@RalfJung RalfJung deleted the miri-no-copy branch May 29, 2024 18:42
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Jun 9, 2024
Add a benchmark for creating large uninit allocations

Extracted from rust-lang/miri#3637

I used this program to confirm that rust-lang#125633 has the desired effect.
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.

Big Vec::try_reserve OOMs Miri (slowly)
4 participants