cmake: kconfig: stop rehashing every Kconfig source on re-configure - #117017
Open
kartben wants to merge 2 commits into
Open
cmake: kconfig: stop rehashing every Kconfig source on re-configure#117017kartben wants to merge 2 commits into
kartben wants to merge 2 commits into
Conversation
The checksums are accumulated with set(var "${var}${checksum}") in loops
that run once per parsed Kconfig file, 5001 of them for a hello_world
build. CMake strings are immutable, so every iteration copies the whole
accumulator and the loops are quadratic.
Accumulate with string(APPEND) instead, and register the configure
dependencies in a single set_property() call rather than one per file.
Measured in isolation over 5001 sources, a checksum loop goes from
168 ms to 123 ms and the dependency registration from 8 ms to 2 ms. The
resulting checksum is byte-identical.
Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
…used The loop that recalculates the checksum after kconfig.py runs is only consumed inside if(CREATE_NEW_DOTCONFIG). On any configure that does not regenerate .config its result is discarded, so hashing all 5001 parsed Kconfig sources is pure waste, measured in isolation at 168 ms. Move the loop into the block that consumes it. The file(STRINGS) read above stays where it is, as it also feeds the CMAKE_CONFIGURE_DEPENDS registration, which must keep running unconditionally. Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
kartben
force-pushed
the
cmake-kconfig-checksum
branch
from
August 21, 2026 08:30
5633193 to
0b722b4
Compare
kartben
marked this pull request as ready for review
August 21, 2026 08:55
zephyrbot
requested review from
57300,
jeremybettis,
nashif,
nordicjm and
tejlmand
August 21, 2026 08:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent cleanups to the Kconfig checksum handling, split into a commit each.
Quadratic accumulation. The checksums are built with
set(var "${var}${checksum}")in loops that run once per parsed Kconfig file — 5001 of them for ahello_worldbuild. CMake strings are immutable, so every iteration copies the whole accumulator.string(APPEND)avoids that, and the configure dependencies are registered in oneset_property()call rather than one per file.Dead work. The loop that recalculates the checksum after
kconfig.pyruns is only consumed insideif(CREATE_NEW_DOTCONFIG). On any configure that does not regenerate.config, its result is discarded — 5001 file hashes for nothing. It moves into the block that consumes it.Measured in isolation over the 5001 sources of a
hello_worldbuild:The resulting checksum is byte-identical —
.cmake.dotconfig.checksumhashes the same at both commits and onmainso cached builds are unaffected.