[PATCH] D90125: [CSSPGO] Infrastructure for context-sensitive Sample PGO and Inlining
David Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 10 18:57:19 PST 2020
davidxl added inline comments.
================
Comment at: llvm/include/llvm/ProfileData/SampleProf.h:361
+// Example of full context string (note the wrapping `[]`):
+// `[main:3 @ _Z5funcAi:1 @ _Z8funcLeafi]`
+// Example of context-less function name (same as AutoFDO):
----------------
wenlei wrote:
> wenlei wrote:
> > davidxl wrote:
> > > The syntax of the context string can probably be made more consistent like:
> > >
> > > SampleContext : LeafContext
> > > : ParentContext LeafContext
> > >
> > > LeafContext: function_name
> > > ParentContext: [ParentFrames]
> > > ParentFrames: OneParentFrame
> > > : ParentFrames OneParentFrame
> > > OneParentFrame: function_name:line @
> > >
> > > So in your example, the full context string should look like:
> > >
> > > [main:3 @_Z5funcAi:1 @] _Z8funcLeafi
> > >
> > Agreed, that's indeed more consistent and I like that better. Thanks for the suggestion. Will make the change (llvm-profgen change will follow too).
> Actually, there're other implication if we were to change context string to be `[context] leaf`. With the currently syntax, when we promote context, new context string is a substring of the original one. So we just create StringRef wrapper for context promotion without creating new strings.
>
> E.g. when `main:3 @ _Z5funcAi:1 @ _Z8funcLeafi` is promoted, it becomes `_Z5funcAi:1 @ _Z8funcLeafi` which is sub string of the original one (StringRef that reuses the underlying string).
>
> If we use `[main:3 @_Z5funcAi:1 @] _Z8funcLeafi`, promotion will lead to something like `[_Z5funcAi:1 @] _Z8funcLeafi`, which is no longer a substring and a new string need to be created. We use two StringRef to represent context part and leaf part today, but we also need a consistent string representation for the full context `getNameWithContext`.
>
> So practically, current syntax is more efficient for context promotion.
>
> Additionally, with the proposed syntax, top level context would look like this `[] main` to differentiate from context-less header. In this case, `[main]` is probably better.
>
> What do you think?
>
> Actually, there're other implication if we were to change context string to be `[context] leaf`. With the currently syntax, when we promote context, new context string is a substring of the original one. So we just create StringRef wrapper for context promotion without creating new strings.
>
> E.g. when `main:3 @ _Z5funcAi:1 @ _Z8funcLeafi` is promoted, it becomes `_Z5funcAi:1 @ _Z8funcLeafi` which is sub string of the original one (StringRef that reuses the underlying string).
In this case, where does the bracket go?
>
> If we use `[main:3 @_Z5funcAi:1 @] _Z8funcLeafi`, promotion will lead to something like `[_Z5funcAi:1 @] _Z8funcLeafi`, which is no longer a substring and a new string need to be created. We use two StringRef to represent context part and leaf part today, but we also need a consistent string representation for the full context `getNameWithContext`.
>
> So practically, current syntax is more efficient for context promotion.
>
> Additionally, with the proposed syntax, top level context would look like this `[] main` to differentiate from context-less header. In this case, `[main]` is probably better.
what is the difference between top level context vs context less header?
>
> What do you think?
>
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90125/new/
https://reviews.llvm.org/D90125
More information about the llvm-commits
mailing list