Grokking Advanced Go
0% completed
Profile Guided Optimization
When the compiler reads a function, how could it know whether that function runs on every request or once at startup? The source does not say, so the compiler applies one general set of rules to all code. It copies only small functions into their callers (inlining), because copying large functions everywhere would make the binary larger with no benefit in rarely used code.
A CPU profile from a real run contains exactly the missing information. What happens if the compiler is given that profile as an input, what does it change in the program, and what does the change cost?
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%