Understanding PGO
Using PGO, we can run the native image with an option to generate a runtime profile. The JVM creates a profile file, .iprof
, which can be used to recompile the native image, to further optimize it. The following diagram (recall it from the Profile Guided Optimization (PGO) section in Chapter 3, GraalVM Architecture) shows how PGO works:
The preceding diagram shows the native image compilation pipeline flow using PGO. Let's understand this flow better:
- The initial native image is instrumented to create a profile by passing the
–pgo-instrument
flag argument, while bundling the native image. This will generate a native image with instrumentation code. - When we run the native image with several inputs, a profile is created by the native image. This profile is a file generated in the same directory with the
.iprof
extension. - Once we have...