Skip to content

A put never compacts (#92) - #93

Open
PaulSnow wants to merge 1 commit into
mainfrom
put-never-compacts
Open

PaulSnow wants to merge 1 commit into
mainfrom
put-never-compacts

Conversation

@PaulSnow

Copy link
Copy Markdown
Contributor

Closes #92.

KVShard.PutDyna, PutPerm and Put ran KV2.CompressCompactHistory synchronously on the calling goroutine once a shard's write count passed 5,000. Nothing scheduled it; it dates from the sharding commit. On the block-committing goroutine that was 3.4 s of every 30 s at nineteen minutes of soak load (profile in #92), growing with history, and in 2 of 20 goroutine snapshots the block loop was inside CompactHistory from PutDyna: once fsyncing the merged segment itself, once waiting on the maintenance lock held by the adapter's own async pass.

Invariant: 1.2 (no protocol-path cost growing with the age of the store) and 1.6 (the protocol path never waits for maintenance). Not in the 2.10 register; this PR closes the gap rather than adding a row. SPEC 2.7 now says nothing on the protocol path starts a pass.

Change

  • kv_shard.go: the three puts no longer compact. Compress stays for the caller's cadence (the accumulate adapter's maintain() already runs it off the protocol path).
  • kv_2.go: PutPerm reports the perm write count (it returned the dyna one).
  • TestPutNeverCompacts: one shard, seal limit 100, 60 blocks past the old trigger with history to fold; the maintenance hook fails the test if CompactHistory runs from inside a put, then an explicit Compress must fold that history so the check is not vacuous. Fails without the fix, passes with it (13 s).

go test ./... passes (22 min on a loaded box; the package ran past Go's default 10-minute timeout on the first try with no failures).

🤖 Generated with Claude Code

https://claude.ai/code/session_015wUZmWRdAPtcfFgYrLJCc5

KVShard.PutDyna, PutPerm and Put each ran KV2.Compress, and so
CompactHistory, on the calling goroutine once a shard's write count
passed 5,000.  Nothing scheduled it; it dates from the sharding
commit.  On the block-committing goroutine that was 3.4 s of every
30 s at nineteen minutes of load, growing with history, and twice in
twenty goroutine snapshots the block loop was caught inside
CompactHistory from PutDyna: once fsyncing the merged segment, once
waiting on the maintenance lock the adapter's own pass held.  Spec
1.2 and 1.6: the protocol path never waits for maintenance.

The puts no longer compact.  Compress stays for the caller's cadence,
which the adapter already runs off the protocol path.  PutPerm now
reports the perm write count instead of the dyna one.

TestPutNeverCompacts drives a shard past the old trigger with history
to fold, fails if CompactHistory runs from inside a put, and then
asserts that an explicit Compress does fold that history, so the
check is not vacuous.  It fails without the fix and passes with it.

Closes #92.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015wUZmWRdAPtcfFgYrLJCc5
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.

A put compacts history on the protocol path: KVShard.Put/PutDyna/PutPerm call Compress every 5,000 writes

1 participant