Record the before and after comparison of track 1

8x1 with the image of edc091d (before) and the one-statement write
(after), alternating per repeat, three repeats at 3 600, 5 400 and
8 100 rps. At 3 600 rps, below the knee, p95 falls from 64.5 ms
(35.7..142.5) to 3.7 ms (2.8..5.4) and p99 from 122 to 13 ms; the API
spends 391 instead of 457 % CPU and PostgreSQL 102 instead of 137 %;
connections waiting for a chat lock drop from 12.8 to 0.15 and none is
idle in transaction any more. Past the knee the peak rises from 4 252
(4 054..4 396) to 4 894 rps (4 494..5 104), +15 %, and at 8 100 rps
from 4 104 to 4 841 (+18 %); the ranges do not overlap. Saturated, the
lock holders now wait for the WAL flush (LWLock WALWrite) instead of
the application.

The switch to the after image for the third repeat failed in compose
while another lab was running tests on the shared VM, so that repeat
was run alone with --first-repeat 3 on the same database; apply now
retries compose up twice and prints its stderr. Two after rows were
still marked disturbed after three reruns and are kept; they are the
lower ones.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
Artyom
2026-10-29 01:37:34 +03:00
co-authored by Claude Opus 5.5
parent 296e070eba
commit dde113b4ed
131 changed files with 20158 additions and 3 deletions
@@ -0,0 +1,21 @@
calls,total_ms,mean_ms,rows,shared_blks_hit,shared_blks_read,query
143412,1940407.723,13.530,143412,3041579,0,"SELECT c.id, c.title, c.created_at, c.last_message_at, ARRAY(SELECT user_id FROM chat_members WHERE chat_id = c.id ORDER BY position) AS member_ids FROM chats c WHERE c.id = $1 FOR UPDATE"
142267,20501.125,0.144,142267,5637447,6,"WITH message AS ( INSERT INTO messages (id, chat_id, sender_id, text, created_at) VALUES ($1, $2, $3, $4, $5) RETURNING id, chat_id, sender_id, created_at ), receipt AS ( INSERT INTO idempotency_keys "
143412,1974.461,0.014,0,573648,0,"SELECT k.fingerprint, m.id, m.chat_id, m.sender_id, m.text, m.created_at FROM idempotency_keys k JOIN messages m ON m.id = k.message_id WHERE k.chat_id = $1 AND k.user_id = $2 AND k.key = $3 AND k.cre"
35633,1938.593,0.054,1814203,1967504,0,"SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = $1 ORDER BY created_at, id LIMIT $2"
35633,1087.037,0.031,35633,347855,0,"SELECT c.id, c.title, c.created_at, ARRAY(SELECT user_id FROM chat_members WHERE chat_id = c.id ORDER BY position) AS member_ids FROM chat_members m JOIN chats c ON c.id = m.chat_id WHERE m.chat_id = "
215165,790.395,0.004,0,0,0,RESET ALL
215165,282.433,0.001,215165,0,0,SELECT pg_advisory_unlock_all()
1145,176.206,0.154,1145,45563,0,"WITH message AS ( INSERT INTO messages (id, chat_id, sender_id, text, created_at) VALUES ($1, $2, $3, $4, $5) RETURNING id, chat_id, sender_id, created_at ), receipt AS ( INSERT INTO idempotency_keys "
215165,41.242,0.000,0,0,0,CLOSE ALL
143462,39.450,0.000,0,0,0,COMMIT
215165,24.933,0.000,0,0,0,UNLISTEN *
143462,22.901,0.000,0,0,0,BEGIN
6,5.269,0.878,12,216,0,"WITH RECURSIVE typeinfo_tree( oid, ns, name, kind, basetype, elemtype, elemdelim, range_subtype, attrtypoids, attrnames, depth) AS ( SELECT ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.elemtype, t"
20,1.454,0.073,20,270,0,"WITH expired AS (DELETE FROM sessions WHERE user_id = $2 AND expires_at <= $3) INSERT INTO sessions (token_hash, user_id, created_at, expires_at) VALUES ($1, $2, $3, $4)"
20,1.417,0.071,20,184,0,"INSERT INTO users (id, username, display_name, password_hash, created_at) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (username) DO NOTHING RETURNING $6"
6,1.145,0.191,12,238,1,"INSERT INTO chat_members (chat_id, user_id, position, chat_created_at) SELECT $1, member.user_id, member.position, $3 FROM unnest($2::uuid[]) WITH ORDINALITY AS member (user_id, position)"
4,0.449,0.112,8,124,0,"INSERT INTO chat_members (chat_id, user_id, position, chat_created_at) SELECT $1, member.user_id, member.position, $3 FROM unnest($2::uuid[]) WITH ORDINALITY AS member (user_id, position)"
391,0.393,0.001,391,0,0,SELECT 1
32,0.336,0.011,32,96,0,"SELECT token_hash, user_id, created_at, expires_at FROM sessions WHERE token_hash = $1 AND expires_at > $2"
20,0.263,0.013,20,60,0,"SELECT id, username, display_name, password_hash, created_at FROM users WHERE username = $1"
1 calls total_ms mean_ms rows shared_blks_hit shared_blks_read query
2 143412 1940407.723 13.530 143412 3041579 0 SELECT c.id, c.title, c.created_at, c.last_message_at, ARRAY(SELECT user_id FROM chat_members WHERE chat_id = c.id ORDER BY position) AS member_ids FROM chats c WHERE c.id = $1 FOR UPDATE
3 142267 20501.125 0.144 142267 5637447 6 WITH message AS ( INSERT INTO messages (id, chat_id, sender_id, text, created_at) VALUES ($1, $2, $3, $4, $5) RETURNING id, chat_id, sender_id, created_at ), receipt AS ( INSERT INTO idempotency_keys
4 143412 1974.461 0.014 0 573648 0 SELECT k.fingerprint, m.id, m.chat_id, m.sender_id, m.text, m.created_at FROM idempotency_keys k JOIN messages m ON m.id = k.message_id WHERE k.chat_id = $1 AND k.user_id = $2 AND k.key = $3 AND k.cre
5 35633 1938.593 0.054 1814203 1967504 0 SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = $1 ORDER BY created_at, id LIMIT $2
6 35633 1087.037 0.031 35633 347855 0 SELECT c.id, c.title, c.created_at, ARRAY(SELECT user_id FROM chat_members WHERE chat_id = c.id ORDER BY position) AS member_ids FROM chat_members m JOIN chats c ON c.id = m.chat_id WHERE m.chat_id =
7 215165 790.395 0.004 0 0 0 RESET ALL
8 215165 282.433 0.001 215165 0 0 SELECT pg_advisory_unlock_all()
9 1145 176.206 0.154 1145 45563 0 WITH message AS ( INSERT INTO messages (id, chat_id, sender_id, text, created_at) VALUES ($1, $2, $3, $4, $5) RETURNING id, chat_id, sender_id, created_at ), receipt AS ( INSERT INTO idempotency_keys
10 215165 41.242 0.000 0 0 0 CLOSE ALL
11 143462 39.450 0.000 0 0 0 COMMIT
12 215165 24.933 0.000 0 0 0 UNLISTEN *
13 143462 22.901 0.000 0 0 0 BEGIN
14 6 5.269 0.878 12 216 0 WITH RECURSIVE typeinfo_tree( oid, ns, name, kind, basetype, elemtype, elemdelim, range_subtype, attrtypoids, attrnames, depth) AS ( SELECT ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.elemtype, t
15 20 1.454 0.073 20 270 0 WITH expired AS (DELETE FROM sessions WHERE user_id = $2 AND expires_at <= $3) INSERT INTO sessions (token_hash, user_id, created_at, expires_at) VALUES ($1, $2, $3, $4)
16 20 1.417 0.071 20 184 0 INSERT INTO users (id, username, display_name, password_hash, created_at) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (username) DO NOTHING RETURNING $6
17 6 1.145 0.191 12 238 1 INSERT INTO chat_members (chat_id, user_id, position, chat_created_at) SELECT $1, member.user_id, member.position, $3 FROM unnest($2::uuid[]) WITH ORDINALITY AS member (user_id, position)
18 4 0.449 0.112 8 124 0 INSERT INTO chat_members (chat_id, user_id, position, chat_created_at) SELECT $1, member.user_id, member.position, $3 FROM unnest($2::uuid[]) WITH ORDINALITY AS member (user_id, position)
19 391 0.393 0.001 391 0 0 SELECT 1
20 32 0.336 0.011 32 96 0 SELECT token_hash, user_id, created_at, expires_at FROM sessions WHERE token_hash = $1 AND expires_at > $2
21 20 0.263 0.013 20 60 0 SELECT id, username, display_name, password_hash, created_at FROM users WHERE username = $1