Use a simple arena for annotatable items - #162006
Conversation
|
Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs cc @ZuseZ4 |
|
@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.
Use a simple arena for annotatable items
|
The job Click to see the possible cause of the failure (guessed by this bot) |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (fc9f757): 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 (primary 3.5%, secondary -3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 475.389s -> 502.254s (5.65%) |
|
Damn, I think I benchmarked this with an unrelated change before, and the win came from that change alone. Good thing I didn't do the painful refactoring :D Nevermind, closing. |
When profiling bors with
dhat, this was one of the places that were kinda hot for allocations. So I tried to use an amortizedVecfor the annotatable items. I didn't store it inMacroExpander, because those are created repeatedly, but rather inExtCtxt, so that it survives over multiple expansion calls, and the memory can be better reused.Since we already pass
&mut ExtCtxtto the expansion functions, I couldn't easily pass&mut Vec<Annotatable>to all the expansion functions too, because that would be a double&mutreference. So as an experiment for a benchmark, I just switched all the functions to directly push to the arena inExtCtxt. This is not super pretty and only works since theExtCtxtis currently not used from multiple threads. I wanted to refactor it, but I figured that it's maybe not so egregious? So first wanted to get a second opinion before I do that.If we wanted to do this via
&mut Vec<Annotatable>, I could storeRefCell<Vec<Annotatable>>inExtCtxt, andborrow_mut()it just before calling the expansion. But for that to work, I'd probably have to replace&mut ExtCtxtin the expansion calls (which might? be possible), or storeRc<RefCell<Vec<Annotatable>>>instead.r? nnethercote