Skip to content

Number of merged contexts in SPMI collections differs significantly between platforms #112380

@amanasifkhalid

Description

@amanasifkhalid

For the current (GUID: cc0e7adf-e397-40b6-9d14-a7149815c991) iteration, benchmarks.run_pgo has 95,310 contexts, of which 45,556 are FullOpts, on win-x64. On win-x86, this same collection has 124,430 collections, of which 81,492 are FullOpts. While some nominal variation in total context count is expected due to platform-specific implementation details, having almost twice as many optimized contexts is odd. @AndyAyersMS clarified that this discrepancy is likely due to how different contexts for the same method are consolidated when we have PGO data (notice how this discrepancy isn't nearly as dramatic for collections without tiering).

mcs currently identifies duplicate contexts to remove by comparing their hashes (see src/coreclr/tools/superpmi/mcs/removedup.cpp). This means mcs isn't all that nuanced in deciding whether to keep duplicate contexts with different profiles: Methods with identical profile counts are removed, but trivial differences in counts are enough to discern between two contexts. Thus, slight differences in profile count precision between platforms can significantly influence the number of duplicate contexts in the final collection.

This complicates analyzing diffs. Ideally, collections across platforms would be as similar as possible to facilitate triage, but removing profile data from the hash computation entirely such that no duplicates are removed would probably be impractical for collection sizes. It might be worth trying something more sophisticated for differentiating contexts based on their profiles; for example, maybe the profile counts should have to be different enough such that the likeliest branch out of a block changes in order for the profiles to be considered unique. However, it isn't clear to me how we would evaluate the efficacy of such a change.

For now, I think we all ought to be aware of this next time we encounter different amounts of churn across platforms. cc @dotnet/jit-contrib

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions