Skip to content

Count version-store outcomes and add an N-replica harness #703

Done

Description

@HMarzban

Parent

#363 (Stage 0 of the N-replica save plan, research of 2026-11-06).

Benchmark

This issue builds the baseline tool. Its numbers are the before for #704 and #706.

Field Value
Metric Unnamed version rows per minute per pad, with typers on k of R replicas (R = 2, 3; k = 1..R). Lock skips and job-id dedupes (count). document_store_outcome_total by outcome (count, seeded at 0). Ladder, one room, N = 40 sockets, R = 2: hot-replica CPU, nodejs_eventloop_lag_max_seconds and nodejs_eventloop_lag_p99_seconds, RSS. Production: unnamed websocket rows per co-edited pad-minute; adjacent byte-equal unnamed pairs over all adjacent pairs. The rollout PUBSUB read lives in #705 Step 0.
Before Local, 2026-11-16 to 2026-11-18, n = 5 per cell (Measured): rows per minute 0.90 with 1 typer, 1.90 with 2 and 2.90 with 3, at R = 2 and R = 3, both fixtures. Lock skips and job-id dedupes 0. Only inserted moves. Ladder, R = 2, N = 40, 1 typer: hot-replica lag max 15.8 ms on 2 KB and 28.1 ms on 500 KB. Production: not measured yet: the maintainer runs the aggregate SQL over 7 days from 2026-11-11 08:34Z, and posts counts here and on #706 by 2026-11-19. The post lists every deploy inside the window.
After not measured yet. The outcomes unchanged, head-moved and coalesced move only after #704 and #706, so this issue has no after of its own.
Condition Named laptop, Bun 1.4.4, apps/hocuspocus.server/scripts/lib/prodModeStack.ts with the Redis extension, commit SHA recorded. Typer at 5 characters per second, 10 minutes per run. Fixtures: the 2 KB fixture and the seed 726 fixture (about 3.6 MB). The seed 726 rows are context, no claim: #706's local bar is absolute, and #704 and #726 use bench-content-write.ts. Production: deployed SHA, collab database in London on PostgreSQL 18.6.
How to run apps/hocuspocus.server/scripts/redis-sync-probe.ts in N-instance mode on prodModeStack.ts. The probe builds the 2 KB fixture from a fixed seed. Pass --fixture <path> for the seed 726 fixture. Production rows: the aggregate SQL below. Rows-per-minute before: jobs_total{queue="store-documents",status="completed"} and a Documents row count.
Pass rule No pass bar: this is a baseline. Done when the table and the ladder are posted at n = 5 per cell. Stop rule: none, because no behaviour changes. Gate floor, for #706: if coedited_pad_minutes is below 30, the read is a hint, and the #706 gate stays shut.
Guard The panel and the seeded counter add no save-path change. No content-safety list is needed.
Owner Agent in the repo: probe, local runs and the panel. Maintainer: production SQL.
Claim None for marketing. It is the ledger before for #704 and #706.

Why

Each collab replica with a local typer runs its own 10 s / 60 s save clock, so version rows grow with the number of replicas. Before any change to the save path, we need counters and a baseline. Every current capacity ceiling predates the awareness guard, the #595 patch and Prisma 7.

What to build

  • Agent in the repo. apps/hocuspocus.server/src/lib/metrics.ts: add document_store_outcome_total{outcome="inserted|unchanged|coalesced|head-moved"}. Seed it at 0 in seedWorkerAlertSeries and seedWsAlertSeries. Amended 2026-11-10: document_store_lock_lost_total moves to Save anyway when the Redis store lock is lost #707.
  • ~~Agent in the repo. apps/hocuspocus.server/src/config/hocuspocus.config.ts (~L128-144): a flag that wires extension-redis in a local harness.~~ Dropped, maintainer ruling 2026-11-11 (ruling). The N-instance probe runs on scripts/lib/prodModeStack.ts, which already starts production mode with the Redis extension.
  • Agent in the repo. apps/hocuspocus.server/scripts/redis-sync-probe.ts (~L199): replace the hard-coded ['A','B'] with an N-instance mode. Build it on scripts/lib/prodModeStack.ts. Its default fixture is a local-only Notes file today. Build the 2 KB fixture from a fixed seed instead, and keep --fixture <path> for the seed 726 fixture.
  • Agent in the repo. A dashboard panel: a document_store_outcome_total rate by outcome in scripts/observability/grafana/provisioning/dashboards/json/app-performance.json.

Measure (local)

Measure (production, maintainer)

Reads only the maintainer runs on production. Window: 7 days from 2026-11-11 08:34Z. Post counts only, here and on #706, by 2026-11-19. The post lists every deploy inside the window.

  • Unnamed websocket rows per co-edited pad-minute, and adjacent byte-equal unnamed pairs over all adjacent pairs. One aggregate-only SQL. A head can hold 12.5 MB, so the query compares lengths first. octet_length reads the stored length without loading the value. Only neighbours of equal length are hashed. Check the cost on a local copy first. Find the cause of the +199.1 MB collab database growth on 2026-11-07 #761 step 3 uses the same form.

    BEGIN READ ONLY;
    SET LOCAL statement_timeout = '120s';
    WITH r AS (
      SELECT id, "documentId", version, "createdAt", contributors,
             octet_length(data) AS len,
             lag(id)                 OVER w AS prev_id,
             lag(octet_length(data)) OVER w AS prev_len
      FROM "Documents"
      WHERE "createdAt" >= '2026-11-11 08:34:00+00'
        AND "createdAt" <  '2026-11-18 08:34:00+00'
        AND trigger = 'websocket' AND COALESCE("commitMessage", '') = ''
      WINDOW w AS (PARTITION BY "documentId" ORDER BY version)
    ),
    m AS (
      SELECT r."documentId", date_trunc('minute', r."createdAt") AS minute,
             count(DISTINCT r.version) AS rows,
             count(DISTINCT c.id) AS editors
      FROM r LEFT JOIN LATERAL unnest(r.contributors) AS c(id) ON true
      GROUP BY 1, 2
    ),
    eq AS (
      SELECT count(*) AS byte_equal_pairs
      FROM r
      JOIN "Documents" a ON a.id = r.id
      JOIN "Documents" b ON b.id = r.prev_id
      WHERE r.len = r.prev_len AND md5(a.data) = md5(b.data)
    )
    SELECT
      count(*) FILTER (WHERE editors >= 2)                    AS coedited_pad_minutes,
      sum(rows) FILTER (WHERE editors >= 2)                   AS coedited_rows,
      round(avg(rows) FILTER (WHERE editors >= 2), 3)         AS rows_per_coedited_pad_minute,
      (SELECT count(*) FROM r WHERE prev_id IS NOT NULL)      AS adjacent_pairs,
      (SELECT byte_equal_pairs FROM eq)                       AS byte_equal_pairs
    FROM m;
    ROLLBACK;

    A pad-minute is co-edited when its rows name 2 or more distinct contributors. prev_id is the previous unnamed websocket row of the same pad. First, the agent checks one fact on a local copy. contributors must hold the editors of that row, not of the whole pad.

  • The 2026-11-06 plan also listed adjacent rows that share one commitMessage. The byte-equal pairs read above replaces it.

  • The PUBSUB NUMSUB read moved to Stop a room on 3 replicas from saving a truncated document during a rolling deploy #705 Step 0. It is a point read. With 2 WebSocket replicas, a channel passes 2 subscribers only during a rollout. So a 7-day window cannot hold it.

Done when

Related

#704 and #706 take their before from this issue. #705 has its own gate read, and owns the rollout PUBSUB read. #726 ran its local before on prodModeStack.ts. #761 step 3 reuses the length-first SQL.

Activity

  1. added this to the v2.3.0 milestone on Nov 6, 2026
  2. added
    Performance
    on Nov 6, 2026
  3. modified the milestones: v2.3.0, v2.3.6 on Nov 9, 2026
  4. HMarzban commented on Nov 10, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-11-10

    Answer: "yes". This trims the issue to what #726 and #704 need. It comes from the storage-at-scale review of 2026-11-10, which found the persist path right-sized for today. During the 2026-11-09 burst the live load was 10-14 sockets and 6-8 rooms, and host CPU stayed at 13.2 % or less.

    The body is amended to match, and each changed line carries this date.

  5. HMarzban commented on Nov 11, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-11-11

    The N-instance probe runs on apps/hocuspocus.server/scripts/lib/prodModeStack.ts, which already starts production mode with the Redis extension. Drop the harness flag in hocuspocus.config.ts. This overturns "Keep: the harness flag" from the 2026-11-10 ruling. Reason: the #726 local before already ran on prodModeStack.ts, and a new flag in production config adds risk for no gain.

  6. modified the milestones: v2.3.6, v2.3.7 on Nov 13, 2026
  7. HMarzban commented on Nov 13, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-11-13: moved to v2.3.7. It cannot finish by the 2026-11-14 cut. Its production read is due 2026-11-19, its local table needs 10 to 11 h of runs, and its consumers #704 and #706 are in v2.3.7.

    SQL fixed in the body. Every autosave stores '', not NULL (apps/hocuspocus.server/src/lib/queue.ts:472). On a local copy, 1,388 of 1,388 websocket rows hold ''. The filter is now COALESCE("commitMessage", '') = '', so the count no longer reads 0 for the wrong reason.

  8. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-16

    This comment covers the agent's code steps and a short local smoke. The 10-11 h table and the ladder have not run yet. Their command is below.

    What changed

    • apps/hocuspocus.server/src/lib/metrics.ts: new document_store_outcome_total{outcome}, with inserted, unchanged, coalesced and head-moved. seedWsAlertSeries and seedWorkerAlertSeries both seed all four at 0. document_store_lock_lost_total is not here, because it moved to Save anyway when the Redis store lock is lost #707.
    • inserted counts once per committed row. It counts in the worker after the FOR UPDATE transaction (src/lib/queue.ts), and in the queue-down fallback (noteFallbackHead). Neither call can throw, and no save behaviour changed. The other three labels have no code path until Skip a save that adds nothing, and merge its contributors #704 and Fold saves into one version per minute per document #706.
    • apps/hocuspocus.server/scripts/redis-sync-probe.ts: --instances N replaces ['A','B']. The new --mode rows puts typers on k of R replicas and adds idle sockets with --sockets. It starts one worker through scripts/lib/prodModeStack.ts. It reports rows per minute, jobs_total completed, outcome deltas, job-id dedupes and lock skips. It also reports CPU, nodejs_eventloop_lag_max_seconds, nodejs_eventloop_lag_p99_seconds and RSS for each replica.
    • Rows mode builds the 2 KB fixture from fixed seed 7 (2,122 B). --fixture-bytes 512000 gives the ~500 KB doc, and --fixture <path> still overrides. The other modes keep their Notes default for now, because Send save confirmations and access frames to local connections only #758 measured on it today.
    • Typers start 60000/k ms apart (--stagger-ms). Typers that start together share one 60 s save clock. In 2 aborted runs (aborted/before-r2k2-1.json, -2.json), the redlock then skipped about 1 save in 2. That is an artifact of the probe, not a production fact. The redlock's DB 0 use is a library fact: @sesamecare-oss/redlock 1.4.0 defaults settings.db to 0 (build/index.js, build/scripts.js), and extension-redis passes only { retryCount: 0 }. Not checked on production.
    • app-performance.json: panel 81, "Document Store Outcomes per Minute". It shows 60 * sum by (outcome) (rate(document_store_outcome_total{job=~"hocuspocus-server|hocuspocus-worker"}[5m])).

    Smoke, before and after the counter

    Apple M5 Max, Bun 1.4.4, HEAD 3bd5ca1c0 plus the uncommitted batch, now committed as 4dae404ec (counter, panel) and bd9c845c5 (probe), local Postgres and Redis DB 6. R = 2, k = 2, 2 KB fixture, 5 characters per second, 3-minute window, worker concurrency 1. Source: probe JSON per run.

    Metric Before (n = 3) After (n = 3) Change
    Rows per minute 1.667 (range 1.667-1.667) 1.667 (range 1.667-1.667) 0%
    inserted in the window absent 5 (range 5-5), equal to rows and to jobs_total completed new series
    Lock skips, window / tail 0 of 5 / 1 of 2 0 of 5 / 1 of 2 no change
    Job-id dedupes 0 0 no change (0 to 0)
    Replica CPU 1.8-1.9 % 1.7-1.8 % noise, no claim

    Other smokes, after the change, n = 1:

    • R = 3, k = 3, 6 sockets, 2 minutes: 2.5 rows per minute, inserted 5. There were 0 lock skips in the window and 2 of 3 in the tail.
    • R = 2, k = 1, seed 726 fixture (3,571,053 B), 2 minutes: 0.5 rows per minute, inserted 1.
    • Label smoke: no series before the seed. All four labels read 0 after the seed and 1 after one increment each.

    When typing stops on every replica at once, the final flushes collide on the redlock. So the tail shows 1 skip per extra replica.

    Gates

    • Prettier check on the 5 touched files: pass.
    • ESLint on the 4 touched TS files: pass. hocuspocus.config.ts is on the ESLint ignore list.
    • bun run typecheck in apps/hocuspocus.server: pass.
    • bun test tests/unit/hocuspocusConfig.test.ts tests/integration/disconnectOnce.test.ts: 15 pass.
    • Dashboard JSON parses. Grafana 13.1.0 provisions panel 81. promtool check rules (prom/prometheus:v3.12.0) accepts the expr.

    Full table and ladder (not run, about 11.5 h)

    Run from apps/hocuspocus.server. Build the seed 726 file first. Its builder (build-seed726-fixture.ts) is a local scratch script, not in the repo yet, so this command cannot run from the repo alone (Left). Then run each line 5 times:

    bun --env-file=../../.env.local scripts/redis-sync-probe.ts --mode rows --redis-db 6 --minutes 10 --instances R --typers k   # R=2: k=1,2; R=3: k=1,2,3
    bun --env-file=../../.env.local scripts/redis-sync-probe.ts --mode rows --redis-db 6 --minutes 10 --instances R --typers k --fixture <out>/seed726.bin
    bun --env-file=../../.env.local scripts/redis-sync-probe.ts --mode rows --redis-db 6 --minutes 10 --instances 2 --typers 1 --sockets 40
    bun --env-file=../../.env.local scripts/redis-sync-probe.ts --mode rows --redis-db 6 --minutes 10 --instances 2 --typers 1 --sockets 40 --fixture-bytes 512000

    Left

    • The full table and the one-room ladder at n = 5. Owner: agent in the repo.
    • Production SQL counts and the deploy list, due 2026-11-19. Owner: maintainer.
    • Local check that contributors holds one row's editors. Owner: maintainer or agent.
    • Flip the default fixture of the other probe modes after Send save confirmations and access frames to local connections only #758 finishes. Owner: agent in the repo.
    • Typers in the ladder: the command uses 1 typer among 40 sockets. Owner: maintainer to confirm.
    • Seen locally: redlock writes the store lock in Redis DB 0 whatever REDIS_DB says. Not checked on production. Owner: maintainer.
    • Make the seed 726 fixture reproducible from the repo, for example a --fixture-seed 726 option on scripts/lib/benchFixture.ts. Owner: agent, before the ladder runs.
    • The WS replicas use the probe's own start(), not prodModeStack.spawnWs, because the Send save confirmations and access frames to local connections only #758 saved mode needs a per-instance env that spawnWs cannot take yet. Move them once it can. Owner: agent.

    After the deploy

    Deployed with (build): front back (06f61ee44, run 43876524495, 2026-11-16 13:31Z, Build Images and Deploy Production success). Read-only, production, 2026-11-16 13:48Z: document_store_outcome_total exists on the worker and the collaboration server. The worker reads inserted = 8; unchanged, coalesced and head-moved read 0, as planned. The panel (AP 81) is live since the observability deploy (288d4d260).

  9. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-16

    Commits a4f4562d8 (spawnWs) and 84993afa8 (probe). The fixture is buildFixture(mulberry32(seed), 3 MiB) from benchFixture.ts, as the #726 runs used, not the bench-content-write.ts text, which seeds each run with seed + run.

    This covers the two agent items under Left in today's earlier comment: the seed 726 fixture, and the move to spawnWs. The 10-11 h table and the ladder have not run. Their command is below.

    What changed

    • apps/hocuspocus.server/scripts/redis-sync-probe.ts: new --fixture-seed <n>. It builds the Cut MCP write time on large pads and stop its four false alerts #726 bench text in the probe: buildFixture(mulberry32(n), 3 MiB) from scripts/lib/benchFixture.ts, then TiptapTransformer.toYdoc with migrationExtensions. It copies the root nodes into a Y.Doc with a fixed client ID (2 ** 31 + seed). No new file. Passing it with --fixture throws before any setup.
    • apps/hocuspocus.server/scripts/lib/prodModeStack.ts: spawnWs(label, base, env = {}). The per-instance env is applied for each replica; the port and health keys still come from spawnWs. On a failed start, spawnWs now kills its own child. bench-content-write.ts keeps calling it with two arguments.
    • The probe's WS replicas start through spawnWs. Saved mode passes A's Redis proxy as env. --log-dir adds REDIS_LOG_LEVEL=warn. The probe's own Postgres TLS proxy is replaced by startPgTlsProxy. Replica logs go to <log-dir>/<label>.log, or else to the scratch dir. A failed run keeps that dir and prints its path.
    • The replicas now also get prodModeStack's offline env: Supabase on a closed port, no email provider, SOCIAL_CARD_KINDS=document. The counts below show no change.

    Seed 726 fixture

    The source is bun -e with the same calls as buildBenchFixture, run from apps/hocuspocus.server.

    • Without a fixed client ID: 2 builds, both 3,571,053 B, with 2 different sha256 values. The transformer's Y.Doc takes a random client ID.
    • With the fix: 3 of 3 builds give 3,571,053 B and sha256 4846310fb835ebe87c026669424f203f05cdc8271bb87781d95379dd2a34f3cd. The ProseMirror JSON equals the transformer's own doc.
    • The size matches the batch 2 scratch file (3,571,053 B). The bytes differ only by the client ID. A 2-byte client ID (726) would give 3,485,217 B.
    • Probe smoke (rows, R = 2, k = 1, 1 min, --fixture-seed 726, n = 1): fixtureBytes 3,571,053, exit 0.

    Before and after the spawnWs move

    Apple M5 Max, Bun 1.4.4, HEAD 288d4d260. Other agents' changes were in the tree, none of them in these two files. Local Postgres and Redis. Before = a frozen copy of the probe at HEAD. After = the edited probe. Same commands, run one after the other. Source: probe JSON for each run.

    Mode and metric Before (n = 3) After (n = 3) Change
    Saved (5,361,363 B Notes fixture, DB 3): document:saved frames per client per save 1 (range 1-1), 20 of 20 on A and on B 1 (range 1-1), 20 of 20 on A and on B none
    Saved: access frames per client 1 (range 1-1) 1 (range 1-1) none
    Saved: drop check, during / after, A 0, 0, 0 / 1, 1, 1 0, 0, 0 / 1, 1, 1 none
    Saved: subscriber sockets cut, A reconnects, relay drops 1, 1, 0 1, 1, 0 none
    Saved: resubscribe ms 632-646 637-649 noise, no claim
    Rows (R = 2, k = 2, 2,122 B fixture, 2 min, DB 4): rows per minute 1.5 (range 1.5-1.5) 1.5 (range 1.5-1.5) 0%
    Rows: window rows / jobs_total completed / inserted 3 / 3 / 3 3 / 3 / 3 none
    Rows: tail rows / inserted 1 / 1 1 / 1 none
    Rows: lock skips, window / tail 0 of 3 / 1 of 2 0 of 3 / 1 of 2 none
    Rows: job-id dedupes, fallback inserted 0, 0 0, 0 none
    Rows: replica CPU 1.0-1.8 % 1.2-1.6 % noise, no claim

    Sanity checks, n = 1 each, no claim:

    • Publishes (10 edits) read 4 publishes per edit, 281,309 bytes per edit, and 10 of 10 delivered, before and after.
    • Convergence (5 rounds) lost 1 before and 2 after. It is a timing race (the baseline was 21 / 9 over 30), so n = 1 says nothing. The restarted B came back on new ports in all 5 rounds.
    • A saved run with --log-dir wrote 24 Redis reconnecting... warn lines to A.log.

    One after-run failed with B never came up, and the agent reran it. The likely cause is a port clash from freePort(), which the old start() used too; no lsof or EADDRINUSE line was saved, so this is not proven.

    Gates

    • bun fmt --check on the 2 files: pass.
    • ESLint (--max-warnings 0) on the 2 files: pass.
    • bun run typecheck in apps/hocuspocus.server: pass, 501 files.
    • No test touches these scripts.

    Full table and ladder (not run, about 11.5 h)

    Run from apps/hocuspocus.server, in bash. It now runs from the repo alone:

    bash -c 'P="bun --env-file=../../.env.local scripts/redis-sync-probe.ts --mode rows --redis-db 6 --minutes 10"; mkdir -p out; for i in 1 2 3 4 5; do for c in "2 1" "2 2" "3 1" "3 2" "3 3"; do set -- $c; $P --instances $1 --typers $2 > out/r$1k$2-2kb-$i.json; $P --instances $1 --typers $2 --fixture-seed 726 > out/r$1k$2-726-$i.json; done; $P --instances 2 --typers 1 --sockets 40 > out/ladder-2kb-$i.json; $P --instances 2 --typers 1 --sockets 40 --fixture-bytes 512000 > out/ladder-500kb-$i.json; done'

    That is 60 runs of about 11-12 min each.

    Left

    • The full table and the one-room ladder at n = 5, with the command above. Owner: agent in the repo.
    • Production SQL counts and the deploy list, due 2026-11-19. Owner: maintainer.
    • Local check that contributors holds one row's editors. Owner: maintainer or agent.
    • Flip the default fixture of the other probe modes after Send save confirmations and access frames to local connections only #758 finishes. Owner: agent in the repo.
    • Typers in the ladder: the command uses 1 typer among 40 sockets. Owner: maintainer to confirm.
    • Redlock writes the store lock in Redis DB 0, whatever REDIS_DB says. Not checked on production. Owner: maintainer.
    • freePort() (scripts/lib/e2eHarness.ts) can return a port that a 127.0.0.1 listener already holds on macOS. Seen once today. Owner: agent, if it shows up again.

    Done today: the seed 726 fixture is reproducible from the repo (--fixture-seed 726), and the probe's WS replicas run on prodModeStack.spawnWs.

  10. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Review, 2026-11-16 (maintainer approved).

  11. HMarzban commented on Nov 18, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-18: the local baseline at n = 5 per cell

    This is the local before for #704 and #706. No behaviour changed, so there is no after here.

    Condition

    • Machine. Apple M5 Max (18 cores, 48 GiB), darwin 27.0.0, Bun 1.4.4.
    • Stack. scripts/lib/prodModeStack.ts: production mode, Redis extension on, local Postgres through the TLS proxy, worker concurrency 1.
    • Probe. scripts/redis-sync-probe.ts --mode rows --redis-db 6 --minutes 10, sha256 9d7615c63a7eda39493965b875323fcbb3d908c1829c941358a07f4a99fb3d0e, unchanged since 84993afa8.
    • Typer. 5 characters per second, 10-minute window, typers staggered by 60 s / k.
    • Fixtures. The 2 KB fixture (seed 7, 2,122 B) and the seed 726 fixture (3,571,053 B).
    • Code. 57 runs at dcd69569b, from 2026-11-16 18:28Z to 2026-11-17 10:36Z. 3 runs at afd06574b on 2026-11-18. Between the two, the save path did not change. The only server change is the ws_disconnects_total counter, which runs on a close.
    • Load. Other jobs ran on the laptop at times during the 57 runs.

    Three runs were run again, each once, with the same command:

    • ladder-500kb-3 and r3k1-726-4 exited 1. The probe's own Postgres connection timed out ("Connection terminated due to connection timeout"). Each run around them passed.
    • ladder-2kb-3 finished, but the laptop went into idle sleep during it (pmset: Idle Sleep 00:36Z, then a 901 s Maintenance Sleep). Both replicas show 899 s of event-loop lag, and the run saved 3 rows, not 9. The new run used caffeinate -i. Every other run has an event-loop lag max under 284 ms.

    The tables use the 3 new runs in place of the 3 old ones.

    Rows with typers on k of R replicas

    Counts are totals over the 5 runs, inside the 10-minute window. Rows per minute is the median (range) of the 5 runs.

    R k Fixture Rows per minute Lock skips Job-id dedupes inserted unchanged coalesced head-moved n
    2 1 2 KB 0.90 (0.90–0.90) 0 0 45 0 0 0 5
    2 2 2 KB 1.90 (1.90–1.90) 0 0 95 0 0 0 5
    3 1 2 KB 0.90 (0.90–0.90) 0 0 45 0 0 0 5
    3 2 2 KB 1.90 (1.90–1.90) 0 0 95 0 0 0 5
    3 3 2 KB 2.90 (2.90–2.90) 0 0 145 0 0 0 5
    2 1 seed 726 0.90 (0.90–0.90) 0 0 45 0 0 0 5
    2 2 seed 726 1.90 (1.90–1.90) 0 0 95 0 0 0 5
    3 1 seed 726 0.90 (0.90–0.90) 0 0 45 0 0 0 5
    3 2 seed 726 1.90 (1.90–1.90) 0 0 95 0 0 0 5
    3 3 seed 726 2.90 (2.90–2.90) 0 0 145 0 0 0 5

    What it shows:

    • Rows grow with k, the replicas that hold a typer, not with R. One typer saves 9 rows in 10 minutes at R = 2 and at R = 3. Each added typer adds 10 rows. A replica with no typer saves no row.
    • The count is the same in every run of a cell, and for both fixtures. The 60 s max debounce sets it, not the document size.
    • Lock skips and job-id dedupes are 0 in every window. Only inserted moves, as expected: unchanged, coalesced and head-moved have no code path until Skip a save that adds nothing, and merge its contributors #704 or Fold saves into one version per minute per document #706.
    • No run took the queue-down fallback (fallbackInserted 0 in all 60).

    The ladder: one room, N = 40 sockets, R = 2, 1 typer

    Median (range) over 5 runs. The hot replica holds the typer. Lag is nodejs_eventloop_lag_max_seconds and nodejs_eventloop_lag_p99_seconds (median of the samples in a run).

    Fixture Hot CPU % Hot lag max, ms Hot lag p99, ms Hot RSS max, MiB Other CPU % Other RSS max, MiB Rows per minute n
    2 KB 1.4 (0.9–1.8) 15.8 (13.1–68.0) 1.20 (1.02–2.18) 142.2 (133.2–144.9) 1.2 (0.8–1.5) 137.9 (130.9–139.9) 0.90 (0.90–0.90) 5
    500 KB (512,334 B) 4.4 (2.6–4.5) 28.1 (19.5–45.9) 2.51 (1.51–3.26) 157.3 (137.1–164.8) 3.8 (2.5–4.2) 157.5 (144.9–169.3) 0.90 (0.90–0.90) 5

    The seed 726 rows are context, with no claim, as ruled.

    Left

    • The production SQL (maintainer), 7 days from 2026-11-11 08:34Z, by 2026-11-19. Post here and on Fold saves into one version per minute per document #706, with every deploy inside the window.
    • Raw JSON: 60 files plus the 3 replaced ones, kept out of git. Rerun any cell with the command above.
  12. HMarzban commented on Nov 24, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-24: production SQL baseline and live outcome counters

    Question: How many unnamed websocket version rows per co-edited pad-minute and adjacent byte-equal pairs happened in the London window (2026-11-11 08:34Z to 2026-11-18 08:34Z)?

    Setup. Read-only Postgres transaction (SET TRANSACTION READ ONLY, statement_timeout = '30s') against the London collab cluster, plus read-only Prometheus document_store_outcome_total and Grafana dashboard check on 2026-11-24 07:15Z.

    Result:

    Metric Value (2026-11-11 08:34Z..2026-11-18 08:34Z)
    coedited_pad_minutes (editors >= 2) 14
    coedited_rows 39
    rows_per_coedited_pad_minute 2.786
    adjacent_pairs (websocket, unnamed) 414
    byte_equal_pairs 5 (1.20 % of adjacent pairs)

    Live document_store_outcome_total & panel (2026-11-24 on e4d36ae0f):

    • Counters: inserted = 135, unchanged = 0, coalesced = 0, head-moved = 0.
    • Grafana dashboard docsplus-app-performance panel "Document Store Outcomes per Minute" is live (60 * sum by (outcome) (rate(document_store_outcome_total{job=~"hocuspocus-server|hocuspocus-worker"}[5m]))).

    Deploys inside the 2026-11-11 08:34Z..2026-11-18 08:34Z window:

    • 43008200172 (2026-11-11 10:59Z, 0b302b222, (build): front)
    • 43224537614 (2026-11-12 13:09Z, 9f132692e, (build): back front)
    • 43434574052 (2026-11-13 13:32Z, 3d90636a9, (build): front back)
    • 43457071472 (2026-11-13 15:53Z, eeb1ab727, (build): back observability)
    • 43474637920 (2026-11-13 17:37Z, 21bce9f71, (build): observability)
    • 43697520137 (2026-11-15 09:05Z, b7888dce1, (build): front)
    • 43851402851 (2026-11-16 10:43Z, a3ef6e83f, (build): front)
    • 43876524495 (2026-11-16 13:31Z, 06f61ee44, (build): front back)
    • 43878530215 (2026-11-16 13:43Z, 288d4d260, (build): observability)
    • 44025904215 (2026-11-17 05:41Z, 28037ba77, (build): front back)
    • 44027220672 (2026-11-17 05:53Z, 45393ece7, (build): observability)
    • 44041325574 (2026-11-17 07:46Z, afd06574b, (build): front back)

    Cross-posted on #706. All acceptance boxes are now met; closing #703.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DevOpsPerformance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions