-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Uniquely identify CGU's and accurately track their size and merges #89308
Comments
I don't think numeric IDs are a good idea, since keeping them stable across changes to the underlying structure is a little painful, and figuring out which module is which is probably also hard. There's some code which generates CGU names already, e.g., around here. My hope is that some of that can be reused for our purposes here. I think the steps here are roughly:
Perf can then take these newly added events and additional_data and display it appropriately. cc @rust-lang/wg-compiler-performance on whether the steps above make sense -- I'm not super (recently) familiar with our measureme APIs and such, I hope I got these mostly right. Of course, can adjust if there's problems. |
It might be that this wants to rely on support similar to the artifact size profiling work @rylev (IIRC) was doing, which is a separate table from events I think? Not sure. |
I'm not sure there's an assumption being made here about this being so, but in case there is, I would just be careful of baking in the assumption that the initial CGU breakdown of two per module is the right approach. Maybe it is, but I just want to question it. For example, you might imagine alternative CGU partitioning scheme in which each CGU is initially just the call graph of one root mono item. (That's a starting point where there would obviously be a lot of duplication between CGUs, but the merging algorithm would take care of that.) Not saying that's a good idea, but it could be. I wish I had more to say than that at this point, but I just haven't thought about the problem enough. |
I think we support an arbitrary amount of extra "args" put onto each event, so we should be fine in that regard. This format also need not be stable, fwiw, though once perf is consuming it we'd want to be careful with breakage. I think more granular names should also integrate fine - I don't expect perf to parse those, just pass through to the UI, initially. |
The CGU name already is a unique identifier: rust/compiler/rustc_middle/src/mir/mono.rs Lines 431 to 449 in 97032a6
If the compiler is invoked with Also, the self-profiling infrastructure will soon grow some functionality for recording non-timing events: #87404. Self-profiling events also can have an arbitrary number of string arguments. It should not be too hard to make the compiler record all the data you need and then write an analysis tool similar to the other tools in measureme. |
Overview
This issue is in relation to optimizing codegen scheduling. To better profile codegen and see where/what we need to optimize, we need to get metrics for individual codegen units. We can uniquely identify CGU's using their names, so there is already a mechanism for tracking individual CGU's.
CGU Size
Tracking CGU size by itself should not be too hard; at some arbitrary point in time we determine the CGU's size and map this quantity to a CGU ID for later lookup. @Mark-Simulacrum mentioned that we should have support for knowing if a CGU is big just because, or because it absorbed other CGU's; and that this is something that should be displayed on perf.r-l.o. my guess is we can do this using a similar structure to what's already in place in
SelfProfiler
:However, as I understand it, this approach ignores tracking which CGU's have been merged together and just informs
us when and where a merge has occurred; shouldn't we also know what got merged? Or does using a
CodegenUnitId
solve this?Lastly, it has been mentioned that the size metric is not currently accurate, and that the quantity of LLVM instructions
might not provide enough insight. Until I know more, I plan on using CGU instruction count as the size metric.
To Do
cc @Mark-Simulacrum
The text was updated successfully, but these errors were encountered: