Conversation

Is there a document somewhere that describes what optimizations PGO opens up? Like I imagine it can say "don't inline this, it doesn't get called" and "inline this, it gets called a bunch", but what else?
1
2
Replying to and
Inlining and the limited partial inlining are of course heavily influenced by it but it does a lot more than that. If you marked a lot of your functions cold / hot and added branch metadata to every if statement with __builtin_expect_with_probability you could get most manually.
1
Replying to and
If you really wanted you could add your own instrumentation and then turn it into metadata within the source code to have the benefits regardless of compilation method. It will easily bitrot and end up with bad coverage and inaccurate metadata unless it's small + mature codebase.
Replying to
Is there a doc with all of this? I actually don't even know how code tells a branch predictor "this is the likely branch", although I know that gcc had a 'likely' builtin iirc. I see you mentioned a builtin, I'll check that out too.
1
Show replies