Skip to content

perf(control)!: cut per-build control store growth by 40% and prune run logs - #1459

Merged
chio-labs-delivery[bot] merged 11 commits into
mainfrom
perf/recall-footprint
Nov 14, 2026
Merged

chio-labs-delivery[bot] merged 11 commits into
mainfrom
perf/recall-footprint

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Why

A control store grew about 35 MB per DuckShop build and nothing pruned run logs.

Upgrading discards run history. Control stores created by earlier releases are not upgraded: sqb server and sqb dev refuse them and print the command that starts a new, empty store, for example rm -f .sqlbuild/control.sqlite3* for sqb dev, or dropdb … && createdb … for PostgreSQL.

Changes

  • One row per statement when its start and end are written together; started_at sits on that row. Recall schema 6.
  • Lifecycle payloads leave out text and integer fields their columns hold; the events view merges them back.
  • Shorter worker IDs and content hashes; one artifact reference per invocation and digest. Stored 64-digit hashes still deduplicate.
  • Finished runs' worker logs are pruned after 14 days or 200 runs per location target (--run-log-retention-days, --run-log-retention-count). Runs, nodes and scheduler history stay. PostgreSQL stores order invocation_id by bytes.
  • store_bytes in the admin server read, the heartbeat event and Settings.
  • The schema error names the store and the command that recreates it.

Verification

  • Six DuckShop builds on sqb dev, same harness: 34.61 → 20.65 MB per steady build. Remaining growth per build:
Table MB
recall_events (8.4 + 3.0 idx) 11.4
sqb_warehouse_audit_results 4.5
recall_artifact_refs 2.1
recall_artifacts 1.5
recall_output 1.0
everything else 0.2

~1,240 audit_completed events per build carry most payload bytes: audit results are stored twice, as events and in the audit mirror.

  • Old stores are refused with the command on both databases; running it lets the next start succeed.
  • Retention test uses the real claim and finish lifecycle and passes on glibc-collated PostgreSQL; prune ranges use the index on both databases.
  • Native, Python and UI tests.
  • DuckShop: edge_cases/orchestration/run_log_retention.json drives the retention test.

… a batch

Incomplete: part 1 of the per-run footprint change. Recall schema version 6 adds
recall_events.started_at; the statements views read it. Verified with
cargo test -p sqlbuild-recall only.
Relational stores drop payload fields that already have their own column
from sqlbuild lifecycle events; the events view merges them back so the
payload reads as written. Server-produced events keep their payloads.
Worker IDs namespaced by invocation are stored as a 128-bit digest of the
pair instead of the JSON pair. Content digests keep their first 128 bits;
a full-length digest stored earlier still matches. Each invocation writes
one reference per artifact digest; statements and audits find their SQL
and evidence by digest.
…d report store size

A finished run's worker log (events, statements, SQL references and output)
goes whole once it is older than --run-log-retention-days or more than
--run-log-retention-count newer runs finished in its location target. The
run, its node results and the scheduler's events stay. Administrators see
both limits and the store's size; heartbeats report the size too.
…tements

The Settings page shows the control store's size and the run log limits;
the control client carries the new fields.
…t predates this release

A control store created by an earlier release failed with a generic
checksum message. The error now names the SQLite files or the PostgreSQL
database and prints the one command that discards them, so the next
start creates a new store.

BREAKING CHANGE: control stores created by earlier releases are not upgraded, so sqb server and sqb dev start with no run history after upgrading. The server refuses an old store and prints the command that recreates it: for sqb dev, rm -f .sqlbuild/control.sqlite3 .sqlbuild/control.sqlite3-wal .sqlbuild/control.sqlite3-shm in the project; for a PostgreSQL control database, dropdb and createdb on that database.
…enance role

Run log pruning and the store size read move into the platform helpers
that use them, retention settings travel as one named struct, and the
new tests follow the parametrized, branch-free test layout.
A finished run clears its worker instance, so run log retention matched
no run on a real store. Retention now links a run to its worker log
through the scheduler's run_claimed event, and the test claims and
finishes runs through the real lifecycle. PostgreSQL control stores
order invocation_id by bytes, so a worker's prefix range finds its nested
invocations through the index under any database collation.

Real payload fields stay stored, because SQLite and PostgreSQL JSON
functions do not print them back digit for digit. The recreate message
says a different release made the store, names the socket directory for
socket connections and says that dropdb removes the whole database.
The bundled skill joins SQL and audit evidence by digest.
# Conflicts:
#	crates/sqlbuild-orchestration/tests/runs/test_contracts.rs
#	crates/sqlbuild-orchestration/tests/runs/test_types.rs
#	src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/server.md
#	website/src/content/docs/docs/cli/server.mdx
@kvlonge kvlonge added the full-verify Run the full Verify matrix on this pull request label Nov 13, 2026
@chio-labs-delivery
chio-labs-delivery Bot added this pull request to the merge queue Nov 14, 2026
Merged via the queue into main with commit e03dc83 Nov 14, 2026
53 checks passed
@chio-labs-delivery
chio-labs-delivery Bot deleted the perf/recall-footprint branch November 14, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-verify Run the full Verify matrix on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant