-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix #124275: Implemented Default for Arc<str>
#124640
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
I think the |
This comment has been minimized.
This comment has been minimized.
As per this comment, I've removed the |
This comment has been minimized.
This comment has been minimized.
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged. You can start a rebase with the following commands:
The following commits are merge commits: |
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged. You can start a rebase with the following commands:
The following commits are merge commits (since this message was last posted): |
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged. You can start a rebase with the following commands:
The following commits are merge commits (since this message was last posted): |
@rustbot review |
This PR is now the main solution for #124275 |
Hm, I see that there was an FCP in #124367 (comment) for these APIs, but I'm wondering if there was discussion already on whether these should return new Arc's or a shared Arc for the type (e.g., Arc with an empty string can share a single static, rather than having to allocate each time). r? @dtolnay to make the decision whether to re-evaluate FCP or not (just random roll for libs-api) |
Regarding returning new vs shared Arcs, I think the docs could perhaps be updated to say something like impl Default for (A)Rc<...> {
/// Creates an empty ... inside an `(A)Rc`.
///
/// This may or may not share an allocation with other `(A)Rc`s (on the same thread (for `Rc`)).
fn default() -> Self { ... }
} with the "may or may not" giving wiggle-room to add the "single shared allocation" semantics later (or to decide against it), but without blocking the impls on implementing those semantics now (It'd be doable for the concrete types Footnotes
|
I would expect that a shared allocation would use something like the static empty groups in hashbrown. For |
I hadn't thought of that, but yeah having a @Billy-Sheppard I have a branch with these changes if you'd like to incorporate them into this PR, or perhaps just the first commit with the documentation, and I can submit the implementation as a later PR. |
I forgot to push my amended message, unfortunately the broken merge will still show in the PR comments here (apologies for all those that got pinged, I hadn't realised the merge didn't grab the current upstream. |
This comment was marked as resolved.
This comment was marked as resolved.
Ah yes I was wondering about that (attributing). Good call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I would be interested to review a followup PR that makes these share the same static ArcInner, instead of 6 different effectively-identical ones. The representation I would expect is a 16-byte-aligned static with the following contents:
+---------------+---------------+-+-----------------------------+
| strong count | weak count |0| padding |
+---------------+---------------+-+-----------------------------+
This works as the ArcInner<[T]>
for any align_of::<T>() <= 16
, and also str
and CStr
.
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (496f731): comparison URL. Overall result: ✅ improvements - 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)Results (primary -2.5%, secondary -2.6%)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: 670.24s -> 668.657s (-0.24%) |
Use a single static for all default slice Arcs. Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated". As per rust-lang#124640 (review) r? dtolnay
Use a single static for all default slice Arcs. Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated". As per rust-lang#124640 (review) r? dtolnay
Use a single static for all default slice Arcs. Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated". As per rust-lang#124640 (review) r? dtolnay
Rollup merge of rust-lang#125283 - zachs18:arc-default-shared, r=dtolnay Use a single static for all default slice Arcs. Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated". As per rust-lang#124640 (review) r? dtolnay
With added implementations.
For discussion of #124367 (comment).
Key pain points currently: