Avoid an intermediate vec when ref-decoding to &'tcx [T] - #162350
Avoid an intermediate vec when ref-decoding to &'tcx [T]#162350Zalathar wants to merge 1 commit into
&'tcx [T]#162350Conversation
For !needs_drop types, this should allow decoding directly into the arena-allocated slice. For needs_drop types, the arena already collects into a SmallVec<T>, so this avoids an intermediate conversion from Vec<T> to SmallVec<T>.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Avoid an intermediate vec when ref-decoding to `&'tcx [T]`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (629cf3b): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (secondary 7.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.9%)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: 476.686s -> 477.652s (0.20%) |
|
Hmm, curious that this on its own didn't produce any measurable perf effect. |
|
Based on another perf run of #162287, the changes I saw were noise, so I’ll close this PR and keep it as part of the larger cleanup PR. |
For !needs_drop types, this should allow decoding directly into the arena-allocated slice.
For needs_drop types, the arena already collects into a SmallVec, so this avoids an intermediate conversion from Vec to SmallVec.
I was planning some cleanups to
RefDecodableimpls (#162287), and along the way I noticed that some hand-written impls for slices manage to avoid the overhead of decoding to an intermediate Vec, by instead reading ausizelength and then decoding that many items directly. This matches the format that encoding a vec/slice or decoding to Vec would use.This PR therefore applies that same optimization to the impls generated by
impl_ref_decodable_into_arena!.I extracted this change into its own small PR since it has perf effects.
r? nnethercote (or compiler)