Skip to content

Fleet stops rebuilding the Board for work that did not change - #7

Merged
marvin-bitterlich merged 1 commit into
mainfrom
status-cpu-loop
Nov 6, 2026
Merged

marvin-bitterlich merged 1 commit into
mainfrom
status-cpu-loop

Conversation

@marvin-bitterlich

Copy link
Copy Markdown
Contributor

Why?

After the memory fix in #6, the Fleet daemon still burned more than one CPU core on Platform's busy Board. A copy of that Board ran the daemon at 137% CPU, with its main thread busy 92% of the time, while no work was running.

The loop was not Fleet's own output. fleet/health.json is not a Markdown file, so the Board watcher never sees it, and fleet/status.md was already written only when its bytes changed. The loop came from reads that acted like writes:

flowchart LR
  W[Any scheduling write] --> R[Wake all ~1,460 per-record reconcilers]
  R --> C[Done record: re-apply completion with a fresh read]
  C --> I[Fresh read invalidates the brief, even unchanged]
  I --> B[Index rebuild: re-read settled catalogue and archive state]
  C --> P[Status publication: render, read back and compare status.md]
  C --> A[Check every brief's areas against the repository]
Loading

Each reconciler pass paid for a full index rebuild, a full status render and a full area check, even when nothing had changed. A sweep over the done records took longer than the gap between scheduling writes, so it never drained.

How?

Each step now costs work only when its input changed.

  • Fresh reads. A fresh read records a Board write only when the source on disk differs from the indexed brief, so an unchanged brief keeps the index snapshot.
  • Index rebuilds. The index keeps the decoded settled catalogue and archive state, and reads them again only when the file's identity, size or modification time moves. A reported edit now reads only the edited file.
  • Status publication. Fleet renders fleet/status.md and recounts health only when the store hands back different records. The store returns the same record object until its row changes, so identity is a cheap and exact test. A failed write leaves the status unpublished, so the next pass repairs it.
  • Snapshot problems. Fleet checks a Board snapshot's problems, including area folders, once per snapshot instead of once per read pass.
Copy of the live Board, 180 s after 120 s warm-up Before After
Daemon CPU 137% 41%
Daemon main thread busy 92% 28%

Callouts

  • Done records still wake on every scheduling write. Each done record stays in the scheduler's active set to re-apply its completion to the Board, and the per-record reconcilers listen on list keys. This change makes each wake cheap but keeps the fan-out. Removing it changes when Fleet re-applies completion, so it waits for a maintainer decision.
  • Bookkeeping cache key. The index treats the catalogue and archive state as unchanged while their inode, size and millisecond modification time stay the same. A rewrite to the same size within the same millisecond would be missed until the next change. The catalogue only grows, so the risk is limited to .board-archive.json.
  • Area folders outside the Board. A new repository folder that clears an area warning now shows on the next Board snapshot instead of on the next read pass.

A fresh read of an unchanged brief no longer invalidates the Board index,
the index keeps the decoded settled catalogue and archive state until those
files change, Fleet renders status and counts health only when its records
change, and Fleet checks a snapshot's problems once.
@marvin-bitterlich
marvin-bitterlich added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 3554933 Nov 6, 2026
16 checks passed
@marvin-bitterlich
marvin-bitterlich deleted the status-cpu-loop branch November 6, 2026 20:14
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