-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add cache for allocate_str
#127638
Add cache for allocate_str
#127638
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
We recreate the |
Oh, I didn't realize Does it mean I should put the cache in |
I think changing |
This approach looks elegant! The only problem is that |
yea, we originally restricted it because we didn't have a use case, so it seems fine to just remove the check and permit it |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
Good to know that. I'll remove the kind check then.
…On Sun, Jul 14, 2024, 14:56 Ralf Jung ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In compiler/rustc_const_eval/src/interpret/place.rs
<#127638 (comment)>:
> @@ -1001,7 +1001,20 @@ where
kind: MemoryKind<M::MemoryKind>,
mutbl: Mutability,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
- let ptr = self.allocate_bytes_ptr(str.as_bytes(), Align::ONE, kind, mutbl)?;
+ let tcx = self.tcx.tcx;
+
+ // Use cache for immutable strings.
+ let ptr = if mutbl.is_not()
+ && matches!(kind, MemoryKind::CallerLocation | MemoryKind::Machine(_))
Immutable memory can never be deallocated. And anyway memory in the global
tcx map can also never be deallocated.
—
Reply to this email directly, view it on GitHub
<#127638 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMRDI4RFQOZYHN34V3HDHS3ZMIOI3AVCNFSM6AAAAABKYIFB2CVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCNZWGU4DSNRTGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@bors r+ |
@bors r- actually let's perf it first |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Add cache for `allocate_str` Best effort cache for string allocation in const eval. Fixes [rust-lang/miri#3470](rust-lang/miri#3470).
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (b43ab65): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (secondary 3.7%)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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 700.232s -> 700.469s (0.03%) |
@bors rollup- |
Add cache for `allocate_str` Best effort cache for string allocation in const eval. Fixes [rust-lang/miri#3470](rust-lang/miri#3470).
☀️ Test successful - checks-actions |
Finished benchmarking commit (5c84886): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (secondary -3.4%)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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 700.582s -> 700.173s (-0.06%) |
Best effort cache for string allocation in const eval.
Fixes rust-lang/miri#3470.