Skip to content

Conversation

@slurmlord
Copy link

This change reduces the compile time of the solution by increasing the use of precompiled headers in various projects.
The prioritization of which headers to include was gained by referring to the Build Insights output of VS2022.
The following projects are changed:

  • Core/Libraries/debug
  • Core/Libraries/profile
  • Core/Libraries/WWVegas/WWLib
  • Generals/GameEngineDevice
  • Generals/WW3D2
  • Generals/Tools/W3DViewer
  • Generals/Tools/WorldBuilder
  • GeneralsMD/GameEngineDevice
  • GeneralsMD/WW3D2
  • GeneralsMD/Tools/W3DViewer
  • GeneralsMD/Tools/WorldBuilder

The changes in Core/Libraries/debug and Core/Libraries/profile are a bit more involved than the other libraries, as the previous approach was to just include _pch.h. These have now been changed to explicitly include the headers that are needed, validated by turning precompiled headers off and see that they still compile.

Measuring the impact was done by compiling the presets vc6 and win32-debug with and without this change. 7 timing measurements was taken for each option and then averaged. The PowerShell snippet used to do this is:

# First initialize the build with one compile of the workflow to keep dependencies out of the measurements:
cmake --workflow --preset [vc6|win32-debug]
$measurements = @() ; do { cmake --build build/[vc6|win32-debug] --target clean ; $measurements += Measure-Command { cmake --build build/[vc6|win32-debug] } } while ($measurements.Length -lt 7) ; $measurements.TotalSeconds | Measure-Object -Average

The results were as follows

vc6 win32-debug
Without change 230.92s 97.46s
With change 103.75s 56.49s
Change reduction 127.17s (-55%) 40.97s (-42%)

@xezon xezon added Enhancement Is new feature or request Build Anything related to building, compiling Major Severity: Minor < Major < Critical < Blocker labels Oct 25, 2025
@xezon xezon added this to the Code foundation build up milestone Oct 25, 2025
@slurmlord slurmlord force-pushed the slurmlord/extra-pch branch from 774d1fe to a25b6c9 Compare October 26, 2025 20:35
@slurmlord
Copy link
Author

Rebased with review feedback changes included.

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice speed.

@xezon xezon added the Approved Pull Request was approved label Oct 27, 2025
@xezon xezon changed the title build: Use more precompiled headers to reduce build time build: Use more precompiled headers to reduce build time by around 50% Oct 28, 2025
@xezon xezon merged commit d1c5082 into TheSuperHackers:main Oct 28, 2025
18 checks passed
@slurmlord slurmlord deleted the slurmlord/extra-pch branch October 28, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Pull Request was approved Build Anything related to building, compiling Enhancement Is new feature or request Major Severity: Minor < Major < Critical < Blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants