Skip to content

Commit

Permalink
SCons: Add fast_unsafe option for faster rebuilds
Browse files Browse the repository at this point in the history
This reverts godotengine#53828 which had caused a significant drop in incremental
rebuild time for debug builds (from 10s to 23s on my laptop).

The "faster but unsafe" options are re-added, as well as adding
`max_drift=60` which we didn't use previously.

These options speed up SCons' own processing of the codebase to decide
what to build/rebuild (i.e. the first step before actually calling the
compiler). This will therefore not make much difference for scratch
builds, and is mostly useful for incremental rebuilds (including "null"
rebuilds with no change).

These options are enabled automatically for `debug` builds, unless
`fast_unsafe=no` is passed.
They are disabled by default for `release` and `release_debug` builds,
unless `fast_unsafe=yes` is passed.
  • Loading branch information
akien-mga committed Feb 8, 2022
1 parent 4a2f22d commit d4553c5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loade

# Advanced options
opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", False))
opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True))
opts.Add(BoolVariable("tests", "Build the unit tests", False))
opts.Add(BoolVariable("fast_unsafe", "Enable unsafe options for faster rebuilds", False))
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True))
opts.Add(EnumVariable("warnings", "Level of compilation warnings", "all", ("extra", "all", "moderate", "no")))
opts.Add(BoolVariable("werror", "Treat compiler warnings as errors", False))
opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files", "")
Expand Down Expand Up @@ -360,6 +361,17 @@ if env_base["target"] == "debug":
# working on the engine itself.
env_base.Append(CPPDEFINES=["DEV_ENABLED"])

# SCons speed optimization controlled by the `fast_unsafe` option, which provide
# more than 10 s speed up for incremental rebuilds.
# Unsafe as they reduce the certainty of rebuilding all changed files, so it's
# enabled by default for `debug` builds, and can be overridden from command line.
# Ref: https://github.com/SCons/scons/wiki/GoFastButton
if methods.get_cmdline_bool("fast_unsafe", env_base["target"] == "debug"):
# Renamed to `content-timestamp` in SCons >= 4.2, keeping MD5 for compat.
env_base.Decider("MD5-timestamp")
env_base.SetOption("implicit_cache", 1)
env_base.SetOption("max_drift", 60)

if env_base["use_precise_math_checks"]:
env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"])

Expand Down

0 comments on commit d4553c5

Please sign in to comment.