Skip to content

With ccache, clang-cl writes dependency files through /showIncludes, so the Windows builds are cacheable at last - #524

Merged
ofloveandhate merged 4 commits into
bertiniteam:developfrom
ofloveandhate:ci/windows-ccache-says-why-it-caches-nothing
Nov 4, 2026
Merged

ofloveandhate merged 4 commits into
bertiniteam:developfrom
ofloveandhate:ci/windows-ccache-says-why-it-caches-nothing

Conversation

@ofloveandhate

@ofloveandhate ofloveandhate commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Both Windows jobs run clang-cl through ccache, and for as long as the stats step has existed every call has been uncacheable (Cacheable calls: 0 / 149, Unsupported compiler option: 149 / 149): the saved cache was 13 KB and the C++ test job compiled cold on every run, 32 minutes. The three earlier commits around Windows ccache (87bb4c6, b4884c7, 0d4d2b0) never read that number.

This PR first made the stats verbose and then had ccache write its log, which named the refused option: -clang:-MD, with -clang:-MT<obj> and -clang:-MF<depfile>. CMake's Platform/Windows-Clang.cmake sets those for clang-cl under Ninja on purpose ("Prefer clang-cl's gcc-style depfile over cl-style /showIncludes"), and ccache 4.14.1 (2026-09-27) made ccache reject every /clang: pass-through option by design; 4.14.2 keeps that. They meet on every translation unit. Precompiled headers and debug information were not involved.

The fix: when ccache drives clang-cl, the root CMakeLists.txt sets CMAKE_DEPFILE_FLAGS_<lang> to /showIncludes and the depfile format to msvc, the values CMake's own Windows-MSVC module uses for cl, which ccache supports (it replays the include notes on a hit, so Ninja's dependency parsing still works). The jobs keep CCACHE_SLOPPINESS=pch_defines,time_macros (two targets use a precompiled header) and CCACHE_COMPILERTYPE=clang-cl, and print ccache --show-stats -v. ADR-0076 records the cause and the guardrails: do not revert the override for CMake's preference, do not switch ccache off as a precaution, read Cacheable calls.

This run's Windows jobs should show every call cacheable as misses and a cache save in the tens of megabytes; the first run after that shows hits.

🤖 Generated with Claude Code

ofloveandhate and others added 3 commits November 3, 2026 21:36
…r, and print why any call is uncacheable

Both Windows jobs run clang-cl through ccache, and on 2026-11-01 the wheel job reported 0 of 107 calls cacheable, every one uncacheable, so the saved cache was 12 KB and every run compiled cold (32 minutes for the C++ tests). The non-verbose stats do not say why. Two known refusals are addressed: ccache declines a compile that uses a precompiled header (the CMake cmake_pch) unless its sloppiness allows pch_defines and time_macros, and it must classify the compiler as clang-cl. The stats are now printed verbose, so if any call is still refused the next run names the reason.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… it refuses

With CCACHE_SLOPPINESS and CCACHE_COMPILERTYPE set, the C++ job still reported Unsupported compiler option for 149 of 149 calls, and the statistics do not name the option. The ccache log does, so both jobs now write it and print its first unsupported-option lines and the ccache version after the build.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…so Windows builds are cacheable at last (ADR-0076)

The ccache log named the refused option: -clang:-MD, with -clang:-MT and -clang:-MF. CMake Windows-Clang platform module sets those for clang-cl under Ninja on purpose, preferring the gcc-style depfile over /showIncludes, and ccache 4.14.1 made ccache reject every /clang: pass-through option by design. They meet on every translation unit, so every Windows compile was uncacheable (0 of 149) and the jobs compiled cold on every run.

When ccache drives clang-cl, the root CMakeLists now sets the dependency flags to /showIncludes with the msvc depfile format, the values CMake Windows-MSVC module uses for cl, which ccache supports. The log-file diagnostics leave the workflow; the verbose stats stay as the measurement. ADR-0076 records the cause, the three earlier commits that assumed the cache worked without reading its stats, and the guardrails.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ofloveandhate ofloveandhate changed the title The Windows jobs tell ccache about clang-cl and the precompiled header, and print why any call is uncacheable With ccache, clang-cl writes dependency files through /showIncludes, so the Windows builds are cacheable at last Nov 3, 2026
…ls cacheable, 135 MB and 197 MB saved

The 16 calls still refused are the C files of mimalloc, a FetchContent subproject whose own project() call re-applies the platform defaults in its directory. Every b2 translation unit is cached.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ofloveandhate
ofloveandhate merged commit 63930ab into bertiniteam:develop Nov 4, 2026
92 of 93 checks passed
ofloveandhate added a commit that referenced this pull request Nov 4, 2026
Closes #518.

A computation written out between its stages must continue, after a
restart, with the random draws an uninterrupted run would make. b2 could
set a seed and read it back, but not get the state the draws had
reached, nor set it.

### What changes

- **`RandomState`** (`random.hpp`) holds everything the calling thread's
next draws depend on: the global seed, whether one was chosen, the
ordinal the next `AdvanceSolveSeed` takes, and the thread's `b2rand/1`
draw stream. Its fields are public, and states compare with `==`.
- **`GetRandomState()` and `SetRandomState(state)`** get and set the
calling thread's state. The draws after setting a state are the draws
that followed getting it: tested for every kind of draw, a homotopy's
construction, and a solve.
- **Serialization at the edge.** `ToText()` and
`RandomState::FromText(text)` write and read versioned plaintext,
`b2randstate/1`; `FromText` refuses any other text with
`std::invalid_argument`. Boost.Serialization archives carry that text,
so a state goes through text and binary archives, and MPI. `DrawStream`
gains `ToText`, `FromText` and `==`.
- **Python:** `bertini.random.RandomState` (fields, `to_text`,
`from_text`, `==`, pickling as its text), `get_random_state()` and
`set_random_state(state)`.
- **`DeriveSolveSeed` is `AdvanceSolveSeed`** (Python
`advance_solve_seed`). "Derive" read as a derivative; the function
advances the solve-seed chain one step and returns its new seed. It has
shipped since 3.0.0, so the old names stay as deprecated aliases (C++
`[[deprecated]]`, Python `DeprecationWarning`) until 5.0. The Python
docstring said it drew from the stream; it draws nothing, and now says
so.
- **One source of randomness.** The thread's `std::mt19937` engine and
`ThreadEngine()` are removed. Every draw already came from the draw
stream (ADR-0044) and nothing drew from the engine, so no result
changes; it was a second piece of state that anyone saving the state
would have had to know about.

Per-path and per-worker streams are not part of the state: each is
reseeded from the global seed and its index when it is used (ADR-0071).

### Decisions

ADR-0077 records them, among them two open questions: whether "the
calling thread only" is enough (a program drawing setup randomness on
several threads of its own has a state per thread), and whether a
solve's `ScopedSessionState`, which restores the draw stream and
precision but not the seed or the solve ordinal, should restore the
whole state. ADR-0044's line keeping the engine is annotated. (It is
0077 because 0075 is the interval arithmetic ADR on
`integration/intervals`, #526, and 0076 the clang-cl ccache ADR, #524.)

### Docs

A tutorial, *Continuing a computation with the same random draws*, in
the record-keeping section, and a CHANGELOG entry under 4.1.0.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
ofloveandhate added a commit that referenced this pull request Nov 8, 2026
…FR thread-exit fix (#527), Windows ccache (#524), the random state (#520) and solution metadata JSON (#522)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	CHANGELOG.md
#	docs/adr/README.md
ofloveandhate added a commit that referenced this pull request Nov 8, 2026
…MPFR thread-exit fix, Windows ccache, the random state and solution metadata JSON (#531)

Brings `develop` into `integration/intervals`, so the interval work
builds on what has landed there since the branch was cut:

- #527: the slim Windows conda environment, clang 22 with Visual
Studio's `link.exe`, and the fix for heap corruption when a worker
thread exits on Windows (ADR-0078, ADR-0079).
- #524: ccache caches the Windows builds (ADR-0076).
- #520: the random state can be got and set (ADR-0077).
- #522: a solution's metadata round-trips through exact JSON.

It is a merge, not a rebase, as an integration branch takes its trunk.
Two files conflicted, both lists where each side added entries: the
4.1.0 Added block of the changelog (FLINT here; the random state and
solution metadata on develop) and the ADR index (0075 here; 0076 to 0079
on develop). Both sides are kept, in order. The workflow,
`core/CMakeLists.txt` and `environment-win.yml` merged without conflict,
and `libflint` stays in the slim Windows environment.

One commit beyond the merge: the Windows jobs print FLINT's, GMP's,
MPFR's and MPC's versions with the other main conda packages.

What this run shows for the first time: FLINT linked by `link.exe` on
Windows (#526 linked it with `lld-link`), and `test_flint` under clang
22.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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