This is an archive of the discontinued LLVM Phabricator instance.

[SamplePGO][NFC] Dump function profiles in order
ClosedPublic

Authored by hoy on Aug 16 2021, 10:13 AM.

Details

Summary

Sample profiles are stored in a string map which is basically an unordered map. Printing out profiles by simply walking the string map doesn't enforce an order. I'm sorting the map in the decreasing order of total samples to enable a more stable dump, which is good for comparing two dumps.

Diff Detail

Event Timeline

hoy created this revision.Aug 16 2021, 10:13 AM
hoy requested review of this revision.Aug 16 2021, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2021, 10:13 AM
wlei accepted this revision.Aug 16 2021, 10:22 AM

LGTM,thanks!

This revision is now accepted and ready to land.Aug 16 2021, 10:22 AM
wenlei added inline comments.Aug 16 2021, 10:52 AM
llvm/lib/ProfileData/SampleProfReader.cpp
69–73

This is duplicated of the sorting in SampleProfileWriter::writeFuncProfiles. Can we make a standalone helper in SampleProf.h to avoid duplicate?

hoy added inline comments.Aug 16 2021, 11:16 AM
llvm/lib/ProfileData/SampleProfReader.cpp
69–73

Good call, done.

hoy updated this revision to Diff 366682.Aug 16 2021, 11:16 AM

Addressing Wenlei's comment.

wenlei accepted this revision.Aug 16 2021, 11:19 AM

lgtm, thanks.

This revision was automatically updated to reflect the committed changes.

FYI, I ran into this commit when pulling into our downstream fork because we had some tests comparing expected profile dump output. Usually labeling a commit as "NFC" is reserved for patches that have no externally visible effect, but this changes the output of llvm-profdata show. See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151234.html for recent discussion. I can certainly see this being a bit of an edge case.

(No objection to the patch itself, and we didn't see any ill effect so far, just wanted to mention this in case it was unexpectedly not-NFC, or in case anyone else runs across this commit.)

hoy added a comment.Aug 17 2021, 6:11 PM

FYI, I ran into this commit when pulling into our downstream fork because we had some tests comparing expected profile dump output. Usually labeling a commit as "NFC" is reserved for patches that have no externally visible effect, but this changes the output of llvm-profdata show. See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151234.html for recent discussion. I can certainly see this being a bit of an edge case.

(No objection to the patch itself, and we didn't see any ill effect so far, just wanted to mention this in case it was unexpectedly not-NFC, or in case anyone else runs across this commit.)

Thanks for the heads-up and sorry for the inconvenience. I agree that this patch is not a NFC.