-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Make Rc<T>::deref
and Arc<T>::deref
zero-cost
#132553
base: master
Are you sure you want to change the base?
Conversation
b283c44
to
ae36f44
Compare
This comment has been minimized.
This comment has been minimized.
Would it potentially enable those types to have an ffi compatible ABI? So that they could be returned and passed directly from /to ffi function, like |
This comment has been minimized.
This comment has been minimized.
I think in theory it is possible, at least for sized types, but I am not familiar with how to formally make it so. |
ae36f44
to
0d6165f
Compare
This comment has been minimized.
This comment has been minimized.
0d6165f
to
98edd5b
Compare
This comment has been minimized.
This comment has been minimized.
r? libs |
98edd5b
to
8beb51d
Compare
This comment has been minimized.
This comment has been minimized.
8beb51d
to
d7879fa
Compare
This comment has been minimized.
This comment has been minimized.
d7879fa
to
317aa0e
Compare
@EFanZh Is this ready for review? If so, please un-draft the PR. |
@joboet: The source code part is mostly done, but I haven’t finished updating LLDB and CDB pretty printers. The CI doesn’t seem to run those tests. |
No worries! I just didn't want to keep you waiting in case you had forgotten to change the state. |
f243654
to
1308bf6
Compare
This comment has been minimized.
This comment has been minimized.
873f27a
to
454eccf
Compare
This comment has been minimized.
This comment has been minimized.
e37e38b
to
10a7b54
Compare
☔ The latest upstream changes (presumably #135357) made this pull request unmergeable. Please resolve the merge conflicts. |
10a7b54
to
5cf72c8
Compare
☔ The latest upstream changes (presumably #135396) made this pull request unmergeable. Please resolve the merge conflicts. |
5cf72c8
to
8591208
Compare
8591208
to
9c7e4ba
Compare
This comment has been minimized.
This comment has been minimized.
9c7e4ba
to
e072242
Compare
This comment has been minimized.
This comment has been minimized.
e072242
to
5f9be42
Compare
Hi @joboet: Can I request a perf run to see the impact of this change? |
Sure thing! |
This comment has been minimized.
This comment has been minimized.
Make `Rc<T>::deref` and `Arc<T>::deref` zero-cost Currently, `Rc<T>` and `Arc<T>` store pointers to `RcInner<T>` and `ArcInner<T>`. This PR changes the pointers so that they point to `T` directly instead. This is based on the assumption that we access the `T` value more frequently than accessing reference counts. With this change, accessing the data can be done without offsetting pointers from `RcInner<T>` and `ArcInner<T>` to their contained data. This change might also enables some possibly useful future optimizations, such as: - Convert `&[Rc<T>]` into `&[&T]` within O(1) time. - Convert `&[Rc<T>]` into `Vec<&T>` utilizing `memcpy`. - Convert `&Option<Rc<T>>` into `Option<&T>` without branching. - Make `Rc<T>` and `Arc<T>` FFI compatible types where `T: Sized`.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (00d0a00): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 0.7%, secondary -0.5%)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.
CyclesResults (primary -2.1%, secondary 3.0%)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 sizeResults (primary 0.4%, secondary 1.1%)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.
Bootstrap: 778.16s -> 777.103s (-0.14%) |
Hmm, odd to see both debug and opt binary sizes are bigger with this. Maybe try to find the cause there? Might just be a missing |
@scottmcm: I’m working on it, but it may take some time since it’s being done in my free time. |
5f9be42
to
88a2d49
Compare
☔ The latest upstream changes (presumably #136751) made this pull request unmergeable. Please resolve the merge conflicts. |
Currently,
Rc<T>
andArc<T>
store pointers toRcInner<T>
andArcInner<T>
. This PR changes the pointers so that they point toT
directly instead.This is based on the assumption that we access the
T
value more frequently than accessing reference counts. With this change, accessing the data can be done without offsetting pointers fromRcInner<T>
andArcInner<T>
to their contained data. This change might also enables some possibly useful future optimizations, such as:&[Rc<T>]
into&[&T]
within O(1) time.&[Rc<T>]
intoVec<&T>
utilizingmemcpy
.&Option<Rc<T>>
intoOption<&T>
without branching.Rc<T>
andArc<T>
FFI compatible types whereT: Sized
.