Skip to content

cmd/compile: add test for PGO profiles merged from profiles with different source versions #58101

Open
@prattmic

Description

@prattmic

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:

  1. 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.

  2. When building the Node graph, we will end up with unique Nodes for each of the distinct Functions.

  3. 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 same NodeMap entry.

  4. 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

Metadata

Metadata

Assignees

Labels

NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.TestingAn issue that has been verified to require only test changes, not just a test failure.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions