Menu

#372 Enable /LTCG on Windows for 0.5-2% performance boost

open
performance (1)
5
2022-01-06
2021-11-01
No

See these pages for some background information:
/GL compiler switch https://docs.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-160
/LTCG linker switch https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-160

These options allow the compiler and linker to perform more extensive optimizations. Primarily this allows inlining across translation units, along with some other goodies. In my measurements this improves performance between 0.5% and 2% as measured using 7za.exe b.

These improvements are mostly freebies with little to no downside. The possible downsides include slower link times (although much less so with more recent Visual Studio improvements). There is an incremental switch to LTCG that can offset this cost further, if necessary. From what I can tell this is very minor on 7-Zip specifically. The /GL switch also makes it so that .obj and .lib files can not be safely shared across compiler versions. From what I can tell 7-Zip doesn't do this (it all builds together) so that is not impactful.

1 Attachments

Discussion

  • Igor Pavlov

    Igor Pavlov - 2021-11-02

    Important part of 7-Zip source code is optimized such way, that it doesn't need additional optimizations across different files.

     
    • David Machaj

      David Machaj - 2021-11-02

      You are correct that the most critical code for compressing/decompressing is already highly optimized and there isn't much (if any) room for the compiler to optimize it further.

      The nice thing about this change being a compiler/linker option is that it is "free" performance that benefits the entire program without requiring the difficult tuning that the core algorithm has already received. It should still be helpful to have the non-critical portions of 7-Zip run slightly faster. You can hopefully see for yourself the improvement by recompiling with this change and trying it out on your own device.

       
  • David Machaj

    David Machaj - 2022-01-06

    I was wondering if you think this change is worthwhile, or if the patch should be closed out. Thanks.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.