Skip to content

DeltaChannel put on cold pools

Status: measured 2026-11-14, before public release. Stage 8's README run missed two acceptance bars on the DeltaChannel agent threads of large_threads: put p50 at 1.39×, 1.81× and 1.76× upstream (bar 1.25×), and 1 MB disk at 1.061× (bar 1.05×). This note records where both come from. Every run below has commit.dirty false and host.contended false, and each ratio is between arms of the same run.

Where the put time went (measured)

A bisect of five merges on main, on one dedicated host, each run twice in the order A–E then E–A. Ours' DeltaChannel put p50, with its ratio to upstream in the same run:

Merge What it merged 1 MB 3 MB 10 MB
A Stage 4 tip 2.41, 2.87 ms (1.19×, 1.14×) 2.65, 2.61 ms (1.29×, 1.48×) 2.48, 2.65 ms (1.19×, 0.99×)
B Stage 5: fence and expiry 3.43, 4.16 ms (1.83×, 2.12×) 3.09, 3.68 ms (1.74×, 1.61×) 3.41, 4.29 ms (1.76×, 1.95×)
C The head-row race fix 3.56, 3.72 ms (1.84×, 1.59×) 3.39, 3.20 ms (2.01×, 1.68×) 3.48, 4.09 ms (1.63×, 1.82×)
D Stage 6: listing index 3.40, 3.33 ms (1.56×, 1.41×) 3.30, 3.19 ms (1.86×, 1.91×) 3.59, 3.54 ms (1.83×, 1.43×)
E Stage 7: sync saver 3.37, 3.58 ms (1.75×, 1.94×) 3.26, 3.45 ms (1.88×, 1.92×) 3.66, 3.68 ms (1.81×, 1.87×)

The step is stage 5, in full-copies mode too, so not patching. aput still sends one statement.

Why: planning on a fresh pool (measured, with one inferred step)

large_threads opens a fresh saver and pool for every run of a thread, so each run's puts go to new connections. psycopg prepares one statement per parameter-type combination: pg_prepared_statements after 8 turns on one connection listed PUT_SQL under four prepared names. Postgres custom-plans each one five times per connection before it caches a generic plan. With pg_stat_statements.track_planning on, PUT_SQL's plan time per call on these puts was 0.65–0.86 ms at merge A, and 0.91–1.25 ms at merge E, from a run the harness marked contended, so that range is inferred to hold uncontended. Execution time was about the same at both. Stage 5's fence made the statement larger, and planning it costs more. Forcing generic plans (plan_cache_mode=force_generic_plan) did not lower ours, since a fresh connection still plans once on first use.

Note (2026-11-30): since a5fa49c, aput binds token_seq as text, so psycopg prepares PUT_SQL under one name per connection (inferred from aio.py aput; not re-measured).

The same workload on one saver (measured)

large_threads --warm (added here) grows each thread through one saver and pool, as a long-lived worker holds them. On merge E plus that option, in two runs (measured before public release), ours' DeltaChannel put p50 against upstream:

Run 1 MB 3 MB 10 MB
warm 1 2.26 ms, 1.16× 1.39 ms, 0.81× 1.24 ms, 0.72×
warm 2 1.85 ms, 1.11× 1.38 ms, 1.02× 1.21 ms, 0.75×

Within the 1.25× bar. Two fresh-saver runs of the same commit still read 1.16–2.30×. So the miss is the per-connection planning a fresh pool pays, not the work each put does once its plan is cached.

The 1 MB disk miss (measured)

The harness counts opc_thread_head from merge C on. With one thread's row in it, that table takes 65,536 B after VACUUM, against 16,384 B empty (inferred to be its free-space and visibility maps and a heap page, which appear with the first row). The listing index adds 8,192 B on checkpoints. That is about 56 KB that comes with the first thread, not with each one, and most of the 1 MB thread's excess, which is 41–74 KB above upstream across the runs above. The 3 MB and 10 MB threads read 0.91–0.95× and 0.83–0.85× in every one of them.