-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<functional>: make move_only_function do less work
#5328
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
<functional>: make move_only_function do less work
#5328
Conversation
<functiona>: make move_only_function doing less work<functional>: make move_only_function doing less work
<functional>: make move_only_function doing less work<functional>: make move_only_function do less work
|
Thanks! 😻 On my 5950X I actually observe
However, this case seems unrealistic (how often are users default-constructing and immediately moving), and if the code had originally been written this way, I would never have asked for an additional pointer to be nulled. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
Thanks for improving this code and benchmarking it! ⏱️ 🚀 😻 |
Primarily I treat this more as a clarity improvement.
Yet, the benchmark results prove this PR deserving
performancelabel.Resolves #5316
⏱️ Benchmark results
🥇 Results interpretation
mof_constructis the only that changed more than results variation, it shows some improvement due to doing less work.mof_construct_and_moveaddresses the concern of potential slowdown due to failed store-to-load forwarding.The concern was due to storing zero as one pointer but then loading two pointers, which can be loaded in the same vector register. If the load happens shortly after the store, it has to wait for the store to completely reach the cache, as the wider value cannot be obtained from the narrower store buffer entry.
The situation apparently does not happen, as before the actual two-pointers move, there's vtable obtaining and inspection, which takes enough time for the store to complete.
mof_noneandmof_movegive some idea on the corresponding baseline timings. They are not expected to change.