Skip to content

perf(roadmap): encode only changed records and scan once per repo - #6657

Merged
dan-petty merged 11 commits into
mainfrom
perf/6614-encode-only-changed-records-and-scan-once-per-repo
Nov 21, 2026
Merged

dan-petty merged 11 commits into
mainfrom
perf/6614-encode-only-changed-records-and-scan-once-per-repo

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

A save of the shared listing snapshot encoded, hashed and compressed all records before it found that the save was older or unchanged: about 1.2 s for each unchanged save of devops-cli. A store now compares the records with the records that it last wrote or loaded, and compresses only the records that it sends. An older or unchanged save compresses no record.

Two lanes of one process that loaded one repository at the same time each sent a full HSCAN. A load now takes a lock for its repository, and a lane that waited takes the records of that scan. The load budget also covers the wait, the inflate and the validation. A record under a field that is not its issue number makes the copy a miss.

Local snapshot (6,653 records, fakeredis), main to head: median unchanged save 1.20 s to 0.03 s; peak memory of one load 101 MB to 102 MB, of two loads at once 192 MB to 102 MB.

Closes #6614

Change: openspec/changes/archive/2026-11-21-6614-encode-only-changed-records-and-scan-once-per-repo/

@dan-petty dan-petty added type/infra Type infra: the build, CI, images or cluster scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 21, 2026
@dan-petty
dan-petty force-pushed the perf/6614-encode-only-changed-records-and-scan-once-per-repo branch from 00db3ae to a504d96 Compare November 21, 2026 17:54
Plan the change that makes a save of the shared listing snapshot
compress only the records that it sends, makes the loads of one
repository in a process share one scan, and makes the load budget
cover the wait, the inflate and the validation.
The tests fail on the base: ValkeySnapshotStore has no compress field, and
a save compresses all records before it decides older or unchanged.
A save decides older from the schema key and the watermark before it
encodes a record. A store that knows the stored records compares each
record with the known record of its number, and encodes only the records
that are not equal. It compresses only the records that it sends, through
the new field compress. Only a write to a temporary key encodes and
compresses all records.
ClockFake gets after_each_reading, a test action after each read of the
monotonic clock. The test fails on the base: the second lane sends its own
HSCAN while the first lane scans.
…6614)

A load that misses the known records takes a lock for its repository
before it scans. A load that waited reads the known records again and
takes the records of the scan of the other load. A load with known
records takes no lock.
The tests fail on the base and on the head of the lock for each
repository: a load that passes its budget in its last HSCAN keeps the
shared copy, and a lane that waits past its budget takes the records of
the other lane.
The budget of a shared load starts when the load misses the known
records. The store checks it after the lock, after each HSCAN step but the
last, after each inflated record and after each validated record. A stop
logs the step and counts the existing budget series.
…#6614)

The module and class docstrings, the comment of the load budget and the
intake document say that two lanes that load one repository at the same
time share one scan, that the budget covers the wait, the inflate and the
validation, and that a save compresses only the records that it sends.
…alidation budget and a lost delta (#6614)

A shared copy whose field name is not the number of its record is a miss,
and the next save raises no error. A save of the process during a scan
keeps the records that it wrote, so the next save is a delta. A load that
passes its budget in the validation gives no snapshot. A delta that loses
its transaction writes every record to a temporary key.
…er number (#6614)

A load kept its records as the known records even when a save of the
process kept newer records during the scan, so the next save of the
process wrote every record again. A load now keeps its records only when
the known records are still the ones that it missed.

A shared copy whose field name was not the issue number of its record
passed the load, and each later save of the process raised KeyError. Such
a record now makes the copy a miss, as a record that does not parse does.
@dan-petty
dan-petty force-pushed the perf/6614-encode-only-changed-records-and-scan-once-per-repo branch from a504d96 to 8f3dd4d Compare November 21, 2026 18:25
@dan-petty
dan-petty marked this pull request as ready for review November 21, 2026 18:42
@dan-petty
dan-petty merged commit 04b46ec into main Nov 21, 2026
32 checks passed
@dan-petty
dan-petty deleted the perf/6614-encode-only-changed-records-and-scan-once-per-repo branch November 21, 2026 18:46
@dan-petty

Copy link
Copy Markdown
Owner Author

Check after the release: passed (v0.188.3, Service pod on the new image from 2026-11-21T18:58:38Z). Read only, Prometheus, rate over 30 minutes for each pod:

v0.188.2 (window ends 18:54Z) v0.188.3 (window ends 19:31Z)
CPU of the service container 0.334 cores 0.244 cores (-27%)
Unchanged snapshot saves 176 per hour 187 per hour
  • The workload is about the same, and the CPU is lower by about 0.09 cores. The local measure (1.20 s to 0.03 s for each unchanged save) gives about 0.06 cores for 187 saves an hour, so the change explains most of the difference. One window of each version is no exact proof: other work of the rounds also changes the CPU.
  • devops_cli_valkey_cache_errors_total has no increase in the 30 minutes, so no load stopped at its budget.
  • Snapshot writes: unchanged 187, private 57 and shared 33 per hour. No oversize. Snapshot reads: local 192, private 58 and shared 29 per hour. No unknown and no fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/infra Type infra: the build, CI, images or cluster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(roadmap): encode only changed records and scan once per repo

1 participant