-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use Arena::alloc_from_iter
to avoid redundant vec allocations
#140937
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
base: master
Are you sure you want to change the base?
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Use `Arena::alloc_from_iter` to avoid redundant vec allocations Doesn't show up on my local perf run, but might improve performance by a bit in certain cases. (second commit is a small drive-by cleanup)
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (0c0943e): comparison URL. Overall result: ❌ regressions - 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.3%, secondary 2.8%)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 -0.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: 772.356s -> 773.514s (0.15%) |
Hmm, expected perf to be neutral at worst. That |
@yotamofek note that nalgebra is bimodal and is currently in the bottom state, so this might be spurious. |
Ah, that makes sense, thanks!. Maybe another perf run then? |
I don’t think this commit achieves that, the iterator in question (involving Chain and FlatMap) doesn’t have a size hint that’s usable for pre-allocating the right amount of space in the arena. But pre-allocating is necessary to avoid collecting into a Vec first. It might still be a code cleanup but if potential performance/allocations is the motivation, it seems misguided. |
Please correct me if I'm mistaken, but... Both |
Ah okay, I think what I missed was that the arena also allocates iterators into a (edit: specifically, the arena actually allocates into a |
Doesn't show up on my local perf run, but might improve performance by a bit in certain cases.
(second commit is a small drive-by cleanup)