Repository navigation
Add ceramic reproducer for TOAST-bound drain - #229
Draft
iskakaushik wants to merge 4 commits into
Draft
iskakaushik wants to merge 4 commits into
iskakaushik wants to merge 4 commits into
Conversation
This was referenced Oct 20, 2026
On a production workload the serial queue worker stays pinned while the process uses about 1.3 of 8 cores. Each status transition is a non-HOT update that leaves an out-of-line jsonb value unchanged. walshadow then fetches that value from the shadow, one row at a time on the worker, and each fetch is a bridge fetch_toast plus a replay_lsn round trip. The existing local repro has almost no TOAST and much smaller records, so it overstates gains from per-record CPU work. bench/ceramic reproduces that shape. The hot table has six btree indexes (two partial on status), lz4 nested jsonb two and one chunks wide, row locks before each transition, upserts and checksums. The shadow runs in [toast] mode shadow on PostgreSQL 18. prepare.sh builds a golden snapshot once: a bootstrapped shadow and walshadow state with the daemon stopped and a fixed WAL backlog behind it. run.sh restores the snapshot, resumes the daemon pinned from its persisted floor, drains the identical backlog and prints one line with throughput, the TOAST fetch rate and latency, pump wait and per-thread CPU. A run takes about 35 s, and run-to-run noise is 1-3%. ab.sh interleaves two trees and reports mean, stdev and ratio. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serprex
force-pushed
the
ceramic-reproducer
branch
from
November 20, 2026 04:19
cb13760 to
df36152
Compare
The benchmark used a fresh end LSN on each run and stopped when PostgreSQL saw replay catch up. Replay the same backlog through either feed and measure until ClickHouse acknowledges a fixed end LSN. Verify that archive runs read archived segments. Tune WAL volume and TOAST fetch frequency independently. Report WAL, row, and TOAST batch rates, and alternate run order when comparing builds or read-ahead settings.
Member
|
this benchmark tends to update same row multiple time, which makes TOAST cache appealing, but imo that's non representative when heavy workloads will usually be table-wide updates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
bench/ceramic/, a fixed-backlog drain benchmark shaped after a production workload that walshadow falls behind on.What it reproduces
In production the serial queue worker stays pinned and the pump is blocked on it 60-80% of the time, yet the process uses only 1.0-1.6 of 8 cores. The worker is latency-bound. Most transactions lock a row with FOR UPDATE, then make a non-HOT status update that leaves an out-of-line jsonb value unchanged. walshadow fetches that value from the shadow, one row at a time on the worker. Each fetch is a bridge
fetch_toastplus areplay_lsnround trip, and the worker spends about half its wall time on them. The rest of its time goes to records it discards: row locks, index inserts and TOAST index inserts. The existing local repro has almost no TOAST and records about a sixth the size, so it overstates gains from per-record CPU work.Throughput follows
rec/s = 1 / (c_rec + f * c_fetch), wherefis TOAST fetches per WAL record.How it works
prepare.shbuilds a golden snapshot once (~1.5 min):wal_compression.[toast] mode = "shadow", with production's pool sizes (decoders 16, inserters 16, resolvers 8, bridge workers 8).run.shrestores the snapshot (WAL hard-linked, shadow and state copied to a real disk), starts the daemon pinned and resumes it from its persisted floor. It then drains the identical backlog and prints one summary line.ab.shinterleaves two trees and prints mean ± stdev and the ratio.Validation
All runs pin the daemon to 8 cores, with the source and ClickHouse on their own cores. PostgreSQL 18.6, x86. Shadow, out, spill and source WAL share one EBS volume, as in production. Mean ± stdev of 3 interleaved runs.
c_recis1/rec_s - f * c_fetch. For #222 it can be checked on its own: thewalshadow-queuethread is on CPU 36% of the time at 1.55 µs per record, which matches the derived 1.5 µs. The worker's wall time is its CPU time plus fetch waits, and no thread is saturated. Each fetch is one batch, onefetch_toastand onereplay_lsn.At 4 cores, #222 gets 1.10x over v0.1.4 (234k against 214k). Aiming all transitions at recently inserted rows (
UPD_RECENT_FRAC=1) brings fetches into shared_buffers: c_fetch drops to 28 µs and #222 gets 1.14x. Aiming them all at old rows (UPD_RECENT_FRAC=0) brings #222 to about 1.0x. The 1.8x seen on insert-only runs does not carry over to this shape, because the fetches dominate.WAL record mix, harness against production (% of records): Btree INSERT_LEAF 39.2 / 40.7, Heap LOCK 15.5 / 16.1, Heap INSERT 11.1 / 10.3, COMMIT 6.6 / 8.1, Heap DELETE 5.2 / 6.2, Heap UPDATE 5.1 / 6.6, Btree INSERT_POST 4.0 / 4.3. FPI is 9.8% of records and 64% of bytes here, against 11-17% and 65% in production. Average record size is 761 B against 860 B.
A run takes about 35 s end to end: 3-4 s restore and sync, 25-28 s drain, 1-2 s ack tail. Noise is 1-3% stdev over mean.
Known gaps
c_fetchis 45-54 µs against ~115 µs in production, andfetch_toast33-41 µs against 70-145 µs. The toast relation fits in page cache here, and the CPU is x86 against arm64 in production. So the TOAST share is understated, andc_recdiffers by CPU.🤖 Generated with Claude Code