std: implement clear via truncate#154095
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
cc: @nnethercote |
|
r? @nnethercote |
|
I just wrote a microbenchmark and the difference between the two is still measurable. So I'd prefer to keep the code as is. It would be useful to add a comment explaining why |
|
| @@ -2992,6 +2985,10 @@ impl<T, A: Allocator> Vec<T, A> { | |||
| #[inline] | |||
| #[stable(feature = "rust1", since = "1.0.0")] | |||
| pub fn clear(&mut self) { | |||
| // Though this is equivalent to `truncate(0)`, the manual version | |||
| // optimizes better, justifying the additional complexity | |||
| // (see #96002 and #154095 for context). | |||
There was a problem hiding this comment.
maybe use full URLs for the GitHub issue links so they are navigable from IDEs?
|
@bors r+ rollup |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing a51f3a8 (parent) -> 783062d (this PR) Test differencesShow 156 test diffs156 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 783062d3c612d223e6841db4bbbc9bac4ab31ff4 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (783062d): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 501.019s -> 495.891s (-1.02%) |
|
perf triage: These results are noise, this PR only adds comment. @rustbot label: +perf-regression-triaged |
This gets rid of some
unsafe.truncate(0)is even documented to be equivalent toclear, this makes that equivalence even more obvious.