build: cache C++ and CUDA compilation in container builds - #97
Open
DuncanBetts wants to merge 2 commits into
Open
build: cache C++ and CUDA compilation in container builds#97DuncanBetts wants to merge 2 commits into
DuncanBetts wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e64041e07a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
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.
Container image rebuilds currently discard all previous compiler work whenever
COPY . .changes. In the reproduction below, adding one harmless line to one.cppfile and one.cufile causes all 278 Ninja steps to run again, eventhough 261 of the 263 compiler inputs are unchanged.
Cause. The Dockerfile invokes the C, C++, and CUDA compilers directly and keeps
the build tree inside the invalidated image layer. There is therefore no
compiler-output cache available after a source change. The repository also has
no persistent containerized development-build path.
Fix. Three files:
Dockerfileccache; split out a reusablebuild-envstage; configure CMake's C, C++, and CUDA compiler launchers; retain compiler outputs in a 20 GiB cache mount; print cumulative statisticscompose.yamlREADME.mdpodman compose run --rm buildworkflowThe image build and Compose paths serve slightly different cases:
invalidation, but ccache restores unchanged compiler outputs.
/buildand/ccache, allowing Ninja to skipunchanged targets before ccache is consulted.
Verification. The before and after recordings run the same 100×30 terminal
script against the same checkout:
static_assertto one C++ and one CUDA file;The after recording prints cumulative totals for both builds:
526cacheable calls,261hits, and265misses. The265misses comprisethe initial cold build's
263misses plus the two genuinely changedtranslation units.
Reproduction script (
ninfer-cache-demo.sh):Recording — before:
Recording — after:
Marker timestamps are relative to the start of each recording:
00:00.00200:00.00302:26.133/02:31.94002:26.13502:31.94300:00.004/00:00.00202:26.13902:31.94502:07.750/00:21.83704:33.88902:53.78200:00.005/00:00.003Relevant documentation:
Scope. Build ergonomics only. The runtime stage, installed runtime packages,
CMake targets, generated executables, and inference behavior are unchanged.
Python and ccache are present only in the build environment.
Changes made using AI, with careful steering and review by myself. Thanks for creating Ninfer Neroued, I hope you find these build time savings useful in future work, you can take it as a token of my appreciation :).