This adds profile summary to the sample profile file. This is similar to the changes to the instrumentation based profile. For sample profile, I treat a program line as the unit of summary computation.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I just started looking at this. Some early feedback so we can discuss whether my idea makes sense. Mostly, I'm thinking we want to support summary data in text profiles for testing and debugging. Does that make sense to you?
include/llvm/ProfileData/SampleProfReader.h | ||
---|---|---|
139 ↗ | (On Diff #48087) | Well, this is always exactly one for sampling profiles. There's always one count per line. |
lib/ProfileData/SampleProfReader.cpp | ||
792 ↗ | (On Diff #48087) | s/aftter/after/ I would prefer to see a text version of the summary profile. This is invaluable for generating test cases and general debugging. |
lib/ProfileData/SampleProfWriter.cpp | ||
126 ↗ | (On Diff #48087) | One blank line above, please. |
include/llvm/ProfileData/SampleProfReader.h | ||
---|---|---|
139 ↗ | (On Diff #48087) | I use count to mean samples. The fields of ProfileSummary are named *Counts and in the context of sample profiles, I use those fields to represent samples. Thus, MaxBlockCount contains the max among samples on any given line. |
lib/ProfileData/SampleProfReader.cpp | ||
792 ↗ | (On Diff #48087) | The reason why I decided to compute the summary after reading is that it made generating test cases easy. If it is part of the header, either we need to make it optional (and compute it while reading) or write the summary to the profile file. One thing I want to point out is that I'll add support to llvm-profdata to generate summaries for sample profile after this change. At present, it does generate summaries for instrumented profile, but that also needs to be cleaned up since it uses a different set of cutoffs. |
include/llvm/ProfileData/SampleProfReader.h | ||
---|---|---|
139 ↗ | (On Diff #48087) | Ah, yes, that makes sense. Thanks. |
lib/ProfileData/ProfileSummary.cpp | ||
20 ↗ | (On Diff #48087) | Could you add a comment describing these cutoffs and a general idea of what the numbers are and mean? |
lib/ProfileData/SampleProfReader.cpp | ||
403 ↗ | (On Diff #48087) | I'm wondering if we don't want to do something similar to what we do for instrumented profiles here. We could make up a fake summary for older versions of the profile. Right now, you should be seeing test failures for older binary profiles. Are you not? |
792 ↗ | (On Diff #48087) | OK, thanks. That sounds fine. Still need to s/aftter/after/ in the comment. |
I had refactored the ProfileSummary class and made InstrProfSummary as a derived patch. I have merged in that change and added a SampleProfSummary as a new class and avoided the need to use InstrProf specific terms here.
lib/ProfileData/ProfileSummary.cpp | ||
---|---|---|
20 ↗ | (On Diff #48087) | I've added a comment here. Let me know if you want anything more specific. |
lib/ProfileData/SampleProfReader.cpp | ||
403 ↗ | (On Diff #48087) | In the case of instrumented profile, summary is available only for indexed format. If we read an older version of the profile, the summary is computed after reading the profile. There was only one test case that had a binary format directly checked in and I have fixed that test case. |
Thanks for the new feature! LGTM with one minor nit.
include/llvm/ProfileData/SampleProfReader.h | ||
---|---|---|
299 ↗ | (On Diff #48258) | As a matter of consistency, let's keep the naming to SampleProfile instead of SampleProf. I know it's not really "consistent" because instruction profiles use InstrProf, but at least we make it consistent within the sample profiler :) |