#637

Cut github-actions' shared-store disk writes (~57 MB/h) to what actually changed

Openwiiiimmopened 11d ago

The github-actions pane that fetches for the others writes about 57 MB an hour to its shared store at the default 60 s refresh. Before stealth-factory/opscope#659 the widget wrote nothing. Cut it to what actually changed before stealth-factory/opscope#659 merges.

Context / problem

stealth-factory/opscope#659 (stealth-factory/opscope#633) shares github-actions readings across panes through tc::readings. In its live run with 18 repos, the fetching pane's disk-write counter (write_bytes in /proc/<pid>/io) showed about 57 MB an hour, roughly 1.4 GB a day. It grows with repos and runs. Saving a few kilobytes of API answers per repo should not cost megabytes a minute on disk. Part of stealth-factory/opscope#630.

Likely causes. These are read from the code and need confirming before fixing:

  1. Two copies of every reading. Core stores each reading's value and a "last good" copy. After a successful fetch the two are the same text.
  2. Whole rows rewritten. A changed reading rewrites the whole row (up to about 45 KB for a busy repo), and SQLite's rollback journal writes the changed pages a second time.
  3. Readings that look changed when nothing changed. Core already writes only timestamps when the stored text is identical. 57 MB means most repo readings differ every minute. A time-dependent field in each stored run (for example an elapsed duration for a running job) would do that.

Scope

In:

  • Measure first. Record write_bytes for the fetching pane over at least 5 minutes, at the same repo count as stealth-factory/opscope#659's run, on the stealth-factory/opscope#659 branch. Then find which readings change on each fetch and why.
  • github-actions: store only what GitHub returned. Work out time-dependent figures (age, elapsed duration) when drawing, so an unchanged repo is written as timestamps only.
  • core (tc::readings): do not store the "last good" copy when it is the same as the value. Keep reading older rows written with both. Any other cheap cut found while measuring is in scope too.
  • State the before and after write rates in the PR.

Out:

  • Changing the refresh interval or what the pane shows.
  • Changing the store format in a way older builds cannot read. Columns stay as they are, and store::VERSION stays 1.

Acceptance

  • With 18 repos and nothing new on GitHub, the fetching pane writes no more than about 1 MB an hour, measured the same way as stealth-factory/opscope#659.
  • A busy hour, with new runs arriving, is measured and stated in the PR.
  • A reading stored by the current code still opens, and an older build still reads what the new code writes.
  • github-prs, linear and agent-usage benefit from the core change with no change of their own. Their tests pass.
  • cargo test passes, including check.rs.
Agent notes
  • Stack this on stealth-factory/opscope#659**:** branch from feature/ops-285-github-actions-share-repo-discovery-and-per and open the PR with that branch as its base. Retarget it to main after stealth-factory/opscope#659 merges.
  • Core write paths: core/src/readings/store.rs Store::publish (the identical-value branch updates timestamps only; the comparison covers both value and good_value) and Store::annotate. The cache side is settle() and held_for() in core/src/readings.rs, which both pass good alongside value.
  • For "last good" equal to "value", one compatible option is to write good_value = NULL with good_at set, and have row() fall back to value when good_value is NULL and good_at is present. Check that older builds reading such a row do not lose their kept reading for kept(). An older build's row() returns good: None when good_value is NULL, so decide whether that is acceptable during an upgrade. If it is not, keep writing both and cut elsewhere.
  • Journal: the store uses journal_mode=TRUNCATE and synchronous=OFF. WAL would change what older builds see, so leave the mode alone unless it is shown to be compatible.
  • github-actions: check what ingest_run stores per run, and whether the runs reading includes anything that moves between fetches when GitHub's answer has not changed.
  • Do not use real repo or org names in fixtures or the PR.

Activity

2
linear-code[bot]11d ago
coderabbitai[bot]11d ago
🔗 Related PRs

stealth-factory/opscope#662 - fix(github-actions): write the shared store only what actually changed [open] stealth-factory/opscope#659 - feat(github-actions): share repo discovery and per-repo runs across panes, and stop at the rate limit [closed]


📝 Issue Planner

Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

  • Create Plan

🧪 Issue enrichment is currently in open beta.

You can configure auto-planning by selecting labels in the issue_enrichment configuration.

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

💬 Have feedback or questions? Drop into our discord!