This is an archive of the discontinued LLVM Phabricator instance.

[NFC] FunctionSamples::getEntrySamples -> getHeadSamplesEstimate
ClosedPublic

Authored by mtrofin on Jul 21 2022, 8:39 AM.

Details

Summary

The name getEntrySamples was misleading for 2 reasons. One, it's close in name to Function::getEntryCount, but the equivalent here is getHeadSamples; second, as opposed to the other get* APIs in FunctionSamples, it performs an estimate/heuristic rather than just retrieving raw data (or a non-heuristic derivate off that data, like getMaxCountInside)

The new name should more clearly communicate its intent; and, being close (in name) to getHeadSamples, it should allow the reader discover the relation between them.

Also updated the doc comments for both getHeadSamples[Estimate] so a reader may better understand the relation between them.

Diff Detail

Event Timeline

mtrofin created this revision.Jul 21 2022, 8:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2022, 8:39 AM
mtrofin requested review of this revision.Jul 21 2022, 8:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2022, 8:39 AM
hoy added a comment.Jul 21 2022, 9:36 AM

Thanks for making the change. Agreed that getEntrySamples is confusing when used together with getHeadSamples.

llvm/include/llvm/ProfileData/SampleProf.h
889

nit: how about just name this getEntrySamplesEstimate ? BB is somehow implicated in the contexts where the API is used.

Maybe getEntrySampleEstimate? the heuristic doesn't guarantee we get the counts for entry BB.

Maybe getEntrySampleEstimate? the heuristic doesn't guarantee we get the counts for entry BB.

It does try to offer an estimate corresponding to that, though, if that's missing - hmmm... how about getHeadSamplesEstimate? It corresponds to what we call "head samples" in FunctionSamples (we're really not using "entry" in these APIs); it's discoverable right next to the getHeadSamples() API, and the "estimate" suffix should offer sufficient of a hint that it's a heuristic, and one would then be incentivized to read the docstring. I'd also, then, highlight in the comment the distinction between the two (i.e. one is raw data, while the "estimate" is, well, trying to produce a number using heuristic, etc)

WDYT?

llvm/include/llvm/ProfileData/SampleProf.h
889

Right, but my goal is improving readability by making the name hint sufficiently well to what the function is about, without requiring the engineer wishing to use it also have to go see how it's used (and understand that code, etc).

hoy added a comment.Jul 21 2022, 11:46 AM

Maybe getEntrySampleEstimate? the heuristic doesn't guarantee we get the counts for entry BB.

It does try to offer an estimate corresponding to that, though, if that's missing - hmmm... how about getHeadSamplesEstimate? It corresponds to what we call "head samples" in FunctionSamples (we're really not using "entry" in these APIs); it's discoverable right next to the getHeadSamples() API, and the "estimate" suffix should offer sufficient of a hint that it's a heuristic, and one would then be incentivized to read the docstring. I'd also, then, highlight in the comment the distinction between the two (i.e. one is raw data, while the "estimate" is, well, trying to produce a number using heuristic, etc)

WDYT?

getHeadSamplesEstimate sounds good to me. I don't see a big difference between "head" and "entry" so using one term only should be more clear.

Maybe getEntrySampleEstimate? the heuristic doesn't guarantee we get the counts for entry BB.

It does try to offer an estimate corresponding to that, though, if that's missing - hmmm... how about getHeadSamplesEstimate? It corresponds to what we call "head samples" in FunctionSamples (we're really not using "entry" in these APIs); it's discoverable right next to the getHeadSamples() API, and the "estimate" suffix should offer sufficient of a hint that it's a heuristic, and one would then be incentivized to read the docstring. I'd also, then, highlight in the comment the distinction between the two (i.e. one is raw data, while the "estimate" is, well, trying to produce a number using heuristic, etc)

WDYT?

Good point, I agreed that's better, for the consistency with term Head. Thanks!

mtrofin updated this revision to Diff 446854.Jul 22 2022, 8:43 AM

updated with agreed name

mtrofin retitled this revision from [NFC] FunctionSamples::getEntrySamples -> getEntryBBSampleCountEstimate to [NFC] FunctionSamples::getEntrySamples -> getHeadSamplesEstimate.Jul 22 2022, 8:44 AM
mtrofin edited the summary of this revision. (Show Details)
wenlei accepted this revision.Jul 22 2022, 8:46 AM

lgtm, thanks.

This revision is now accepted and ready to land.Jul 22 2022, 8:46 AM
hoy accepted this revision.Jul 22 2022, 9:06 AM
This revision was landed with ongoing or failed builds.Jul 22 2022, 9:18 AM
This revision was automatically updated to reflect the committed changes.