cmd/compile: add test for PGO profiles merged from profiles with different source versions #58101
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Testing
An issue that has been verified to require only test changes, not just a test failure.
Milestone
Users may be running several slightly different versions of their service in production (e.g., due to staged rollouts).
Then when collecting profiles, those users may, intentionally or unintentionally, collect profiles from multiple different versions of the binary and merge them together for use as the PGO profile.
I believe we already handle these correctly, but it is not intuitive, so we should add tests to ensure this continues to work.
The interesting case are samples in functions that have moved (different StartLine) between profiles A and B:
Profiling merging uses
(StartLine, Name, SystemName, Filename)
as the Function identity key. Thus there will be 2 Functions with the same Name but different StartLine. Samples referencing these functions won't merge because they reference different Function ids.When building the Node graph, we will end up with unique Nodes for each of the distinct Functions.
When processing Nodes to compute weights, we will calculate the same
NodeMapKey
for Nodes from each of the unique Functions (assuming line offsets within the function are unchanged). Thus, we will accumulate weights from the different Functions into the sameNodeMap
entry.IRGraph construction then works as normal, finding merged weights from
NodeMap
entries.This is quite fragile and we could easily break this without tests (or I missed something and it is already broken!)
cc @cherrymui @aclements
The text was updated successfully, but these errors were encountered: