Skip to content

ci: compile DuckDB's C++ through sccache - #32

Closed
fadion wants to merge 2 commits into
mainfrom
ci/sccache-duckdb
Closed

fadion wants to merge 2 commits into
mainfrom
ci/sccache-duckdb

Conversation

@fadion

@fadion fadion commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Phase 1 of the roadmap's "Keep the DuckDB compile out of every build".

What

  • .github/actions/sccache-cpp, a local composite action. It sets CMAKE_C_COMPILER_LAUNCHER and CMAKE_CXX_COMPILER_LAUNCHER to sccache, using the GitHub Actions cache backend. libduckdb-sys forwards both to CMake, so only DuckDB's C/C++ compiles are wrapped. rustc stays with rust-cache.
  • Windows also gets the MSVC developer environment, because CMake ignores a launcher under the Visual Studio generator. libduckdb-sys picks Ninja on its own once ninja is on PATH. The job fails if Ninja is missing, so the launcher can't be ignored silently.
  • The action is used in CI's lint, test and live jobs, and in release.yml.
  • sccache-probe.yml (temporary): cold dev → release → zigbuild builds of schemaic-db with rust-cache off, printing sccache stats after each.

To measure before merging

  • Dev → release hit rate on Windows, macOS and Linux (the release-build stats step).
  • Zigbuild on Linux: whether it misses, as expected, and whether wrapping zig cc works at all.
  • A re-run of the probe hits on its dev build too, which shows the cache persists across runs.
  • The Windows CI leg still builds and tests with Ninja in place of the Visual Studio generator.
  • The total cache size stays under 10 GB.

Then delete the probe, record the numbers in docs/architecture/ (and drop the phase from the roadmap), and merge.

A cold build recompiles the bundled DuckDB's C++ amalgamation, and cold
is every release and every CI run after a new rustc: v0.40.0's runs took
43 min on Windows CI and 34-50 min per release leg, and the first run
under Rust 1.100 took an hour.

libduckdb-sys builds DuckDB through CMake and forwards
CMAKE_C/CXX_COMPILER_LAUNCHER, so setting those to sccache (GitHub
Actions cache backend) wraps exactly DuckDB's compiles and leaves rustc
to rust-cache. A new local action, .github/actions/sccache-cpp, does it
for the three CI jobs and the release. On Windows it also loads the MSVC
developer environment, because CMake ignores a launcher under the
Visual Studio generator and libduckdb-sys picks Ninja only when ninja is
on PATH; the job fails if it is not.

Unmeasured until the probe in the next commit has run: whether a release
build hits the objects CI's dev build stored.
Builds schemaic-db cold in the dev profile, then in release, and on
Linux with cargo-zigbuild as well, printing sccache's stats after each,
with rust-cache off so DuckDB is compiled every time. The release
build's hit rate is the number docs/roadmap.md says to measure before
relying on sccache. Delete before merging.
@fadion

fadion commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Closed without merging. The duckdb crate is built with bundled, which compiles through the cc crate, not CMake, so the launcher variables here were never used. Wrapping cc instead wouldn't help either: the sources are unpacked into a build-script OUT_DIR whose hash changes with the profile and the rustc version, so a release or a new rustc would miss every time. The findings and the remaining option (bundled-cmake + sccache) are recorded in docs/roadmap.md.

@fadion fadion closed this Nov 19, 2026
@fadion
fadion deleted the ci/sccache-duckdb branch November 19, 2026 22:45
fadion added a commit that referenced this pull request Nov 19, 2026
The sccache plan assumed DuckDB compiles through CMake, which forwards
compiler launchers. Under the `bundled` feature it compiles through the
`cc` crate from sources unpacked into the build script's OUT_DIR, whose
path changes with the profile and the rustc version. sccache keys on
those paths, so a release would never hit CI's objects and neither
would the first build after a new rustc.

The attempt (#32) was closed unmerged. The roadmap now holds the
finding, the remaining option (`bundled-cmake` plus sccache, with what
it would change for every build) as an open recommendation, and three
new traps the attempt ran into.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant