main e7b3a25

#1 Log grows ~15x faster than live data under low traffic

state
closed
opened
bnema ·
updated

Observation

On a small, low-traffic deployment (one user, mostly idle overnight), the write-ahead log grows much faster than the live data it holds.

Measured on disk, about 10 hours after the last compaction:

File Size
snapshot (live data after the last compaction) ~3 MB
current log ~51 MB
  • The log received ~48 MB in ~10 h, about 5 MB per hour, for ~3 MB of live data.
  • With the default CompactAfter (64 MB), this means a compaction about every 12 to 13 hours.
  • Each commit is appended and synced to disk, so the write volume translates into I/O and disk wear, not only space.

What is bounded

Disk usage stays bounded by snapshot + CompactAfter: the log is compacted back to the live data, so this is not a space leak.

Open questions

  • Which keys or prefixes produce most of the appended bytes? (Count of records and bytes per key prefix over one log.)
  • Are some writers rewriting values that did not change, or updating frequently (periodic status, timestamps, heartbeats)?
  • Would a read-only tool that summarizes a log file (records, bytes and overwrites per prefix) help diagnose this in general?

Comments1

bnema

Findings from decoding the production log (52.6 MB, 2,889 records, 12,364 ops): - job/ (CI jobs): 51.1 MB, 97% of the appended bytes - runsrc/: 0.5 MB; everything else: about 1 MB - No write rewrote an unchanged value. Cause: write amplification in ermite's CI storage, not in ermite-kv. - Each CIJob value is about 25 KB, and 24.6 KB of it is contexts_json. Most of that is github.event, the full event payload (about 24 KB). - Every step update (UpdateJob -> saveJob) rewrites the whole record, although only the steps change (about 350 bytes). - One job was rewritten about 58 times in a run, so about 1.4 MB per job and about 2 MB per run. The log covers about 25 CI runs, so "low traffic" means a few CI runs per hour. The kv engine behaves as intended: space is bounded by snapshot + CompactAfter. The fix belongs in ermite: store the planned contexts under their own key, written once per job, so step updates rewrite a record of about 1 KB. A read-only log summary tool (records, bytes and overwrites per prefix) would still be useful: a small decoder found this in seconds.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 2

↑↓ moveenter openesc close