KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
2.9k stars 816 forks source link

Evaluate using Profile-Guided Optimization (PGO) and Post Link Optimization (PLO) #3400

Open zamazan4ik opened 7 months ago

zamazan4ik commented 7 months ago

Hi!

Recently I checked Profile-Guided Optimization (PGO) improvements on multiple projects. The results are here. According to the multiple tests, PGO can help with improving performance in many cases. There is at least one performance report where Naga performed faster than glslang, and for Naga PGO effects can be checked here. Since this, I think PGO integration into the glslang would be a good thing to have.

I can suggest the following action points:

Maybe testing Post-Link Optimization techniques (like LLVM BOLT) would be interesting too (Clang and Rustc already use BOLT as an addition to PGO) but I recommend starting from the usual PGO.

Here are some examples of how PGO optimization is integrated in other projects:

arcady-lunarg commented 7 months ago

Better performance would definitely be nice to have, but I don't think PGO is going to get us a 30x speedup, for that we would probably need to do some actual profiling and look at algorithmic improvements.

zamazan4ik commented 7 months ago

Better performance would definitely be nice to have, but I don't think PGO is going to get us a 30x speedup, for that we would probably need to do some actual profiling and look at algorithmic improvements.

Algorithmic improvements are always nice, of course. However, enabling PGO helps even for well-optimized algorithms. Like better hot/cold splits, better inlining, etc. - all these optimizations are helpful for algorithmically-optimized programs too.

How many improvements PGO can bring to glslang - it should be tested. As an estimation, right now I have only Naga benchmarks - more tests should be performed on glslang with PGO.