Skip to content

fix(postgres): chat history slows under concurrent reads - #190129

Merged
VACInc merged 3 commits into
openclaw:mainfrom
etzelm:fix/pg-r2-l3d-history-reader-lane
Nov 18, 2026
Merged

VACInc merged 3 commits into
openclaw:mainfrom
etzelm:fix/pg-r2-l3d-history-reader-lane

Conversation

@etzelm

@etzelm etzelm commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #188956
Related: #197313, #190001 (#197313 tracks the repeated read snapshots inside each history page, which #190001 addresses)

What Problem This Solves

Fixes: on PostgreSQL, chat.history requests queue behind two history workers when several clients load history at once, so tail latency grows with concurrency while the CPU sits mostly idle.

User Impact

User impact: concurrent chat.history on PostgreSQL waits much less for a history worker. Re-measured on current main (medians of 8 interleaved runs per build): at 8 concurrent clients p50 drops from 19.6 to 12.02 ms, p99 from 54.31 to 31.76 ms, and throughput rises from 378.1 to 622.95 requests/s; at 32 clients p99 drops from 163.13 to 103.1 ms. Single-client p50 is unchanged; single-client p99 rose from 15.08 to 17.07 ms over all runs (14.87 to 15.13 ms in the quieter block). SQLite keeps its current lane size.

Cost, measured on the same runs (medians of 8 runs per build):

  • Memory: during concurrent history reads the Gateway runs up to two more transcript isolates (about 57 MiB of heap each). Peak transcript-worker heap rose from 334.1 to 453.6 MiB and peak Gateway RSS from 2,764.9 to 3,153.1 MiB. The extra isolates retire after the pool's existing idle timeout: 45 s and 100 s after load both builds ran the same number of transcript isolates with about the same heap (45 s: 229.4 vs 242.8 MiB; 100 s: 223.8 vs 227.8 MiB). RSS at 100 s was 2,106.1 vs 2,324.7 MiB.
  • PostgreSQL connections: backends for the runtime role peaked at 23 on base and 25 with the change; both were back to 13 after 100 idle seconds. Each extra history isolate can retain up to two idle transports for three minutes; the documented budget (isolates × (active + 2)) now notes up to four history isolates.

Decision for review: should PostgreSQL history use up to four workers, accepting the cost above? This revises the two-worker reader cap from #167295 and #169110 for one lane on one engine.

  • (a) Accept four workers for PostgreSQL history (this PR). Cost: up to two more isolates (about 120 to 124 MiB of worker heap and about 320 to 390 MiB of peak RSS across the two benches below) and two more peak backends, only while history load is concurrent; single-client p99 from 15.08 to 17.07 ms over all runs (14.87 to 15.13 ms in the quieter block). On a host whose CPU is already saturated by other work, the extra workers did not help p99 (see Evidence, block 1).
  • (b) Keep two workers. PostgreSQL history keeps queueing: 5.57 ms of queue wait per worker request at 8 clients, 13.34 ms at 16.
  • (c) Make the larger lane opt-in with a setting. No default cost, but it adds a config surface for an internal pool size, and the default keeps the queueing.
  • (d) A cap of eight. Measured on an older main (see Evidence): lower queue wait at 16 clients, at about two and a half times the extra memory and with more backends.

Recommended: (a). The extra workers exist only on PostgreSQL agent stores and only under concurrent history reads, they retire through the existing idle timeout and cleanup owners, and SQLite, transcript search and every other lane keep the current cap. The memory bound stays fixed (at most four history isolates on any host), and the latency it buys is the symptom #188956 reports.

Why This Change Was Made

On PostgreSQL a history worker spends most of a request blocked in Atomics.wait on bridge replies, so sizing the lane like a CPU-bound reader leaves requests queued while CPU is free. The history lane on PostgreSQL agent stores now gets two workers per CPU above one, capped at four (two on a two-CPU host). Transcript search, the other transcript lanes, and every SQLite lane keep the existing reader size from #167295 and #169110. No new setting.

The database engine is installed during boot, after the lane module is imported, so the history pool now resolves its size on first use instead of at import. Production code: +47/-7 lines ignoring whitespace (the pool options block is re-indented inside the first-use constructor); tests +117; docs +9/-4.

Scope: this closes #188956 (the queueing in front of the history workers). The transaction round trips inside each page are #197313, addressed by #190001; the two touch different files and are measured separately.

Evidence

Evidence files: https://github.com/etzelm/openclaw/tree/assets/pg-r2-l3d-history-reader-lane-evidence/current-main-2026-11-07 (paths below are relative to it; method, host and store in README.md). The earlier bench on 31866655fd6 stays at the root of the same branch.

Acceptance rule: through a running Gateway on PostgreSQL, at 8 or more concurrent clients, queue wait per worker request and p50 drop, throughput rises and p99 at 8 clients drops; single-client latency holds; the memory and backend cost is reported, and the extra isolates retire once history load stops.

  • Tests on this head merged into current main 078033289a3: a per-engine sizing table (src/infra/worker-pool-sizing.test.ts) and a lane test that installs the engine after importing the lane, as boot does (src/config/sessions/session-history-lane-sizing.test.ts: PostgreSQL 4, SQLite 2, search 2). Both pass, as do the consumer suites for the transcript lanes, the search worker, reconcile readiness, the chat history worker and worker-pool preparation: 12 files, 161 tests (tests/unit-head.log). On main the sizing table fails because the resolver does not exist, and the PostgreSQL lane case gets 2 instead of 4 while the SQLite case passes (tests/unit-base-red.log). pnpm check:changed on the merged head passes every check except two repo-wide audits that fail the same way on plain main 078033289a3: changelog attributions (bot credits in CHANGELOG/ files) and the dead export scan (scripts/lib/control-ui-gesture-probe.ts, src/process/command-reservation-census.ts) (tests/check-changed.log, tests/base-changelog-attr.log, tests/base-deadcode.log). CI on 987348094eb was green.
  • After merging main 4a0e45492b8 (head 3e55cf3ef68): main dropped the history worker's prewarmHistory option (improve(sessions): reduce memory for lightweight transcript reads #198512), so the lazy pool no longer passes it; sizing is unchanged. The sizing table, the lane test and the consumer suites above plus the prewarm and history worker lifecycle suites pass: 14 files, 169 tests. One test in session-transcript-worker-lanes.test.ts (releases pressure subscriptions after native settlement and rearms reopened lanes, added on main by fix: reduce Gateway stalls under filesystem pressure #197510) fails on this head and on plain main 4a0e45492b8 alike, 3 of 3 runs each on a macOS arm64 host. pnpm check:changed passes every step except the dead export scan, whose findings are all in files this PR does not touch.
  • Closed-loop chat.history bench on current main: base main 078033289a3 vs this head merged into it, both built with pnpm build. A fresh Gateway on PostgreSQL 17.11 per run, seeded through its own RPCs with 200 sessions (170 sessions across 6 agents with 2 to 4,675 messages each, plus 30 imported Claude CLI sessions with tool rows hidden between visible turns). Limit 100, 45 s per arm, 16 runs (8 per build) in two interleaved blocks (base head head base base head head base). No run was dropped. Medians over all 16 runs (bench/block-all/medians.tsv; every run in bench/block-all/arms.tsv; raw scrapes in bench/runs/):
arm p50 / p95 / p99 ms p99 range requests/s queue wait per worker request handler mean
1 client, base 6.09 / 10.69 / 15.08 12.85 to 51.11 156.4 0.0 ms 5.19 ms
1 client, fix 6.00 / 11.02 / 17.07 11.9 to 106.71 154.4 0.0 ms 5.27 ms
8 clients, base 19.6 / 31.82 / 54.31 28.99 to 161.47 378.1 5.57 ms 19.46 ms
8 clients, fix 12.02 / 19.64 / 31.76 20 to 230.82 622.95 1.23 ms 10.1 ms
16 clients, base 37.66 / 54.15 / 88.16 58.52 to 200.55 411.8 13.34 ms 37.21 ms
16 clients, fix 24.6 / 42.92 / 66.77 45.72 to 499.74 606.65 6.73 ms 23.41 ms
32 clients, base 71.04 / 96.61 / 163.13 90.84 to 421.36 431.7 28.54 ms 72.43 ms
32 clients, fix 48.48 / 84.22 / 103.1 66.74 to 578.74 634.25 17.02 ms 47.23 ms

Queue wait is openclaw_worker_queue_wait_seconds{kind="sessionTranscript"}; handler mean is openclaw_gateway_rpc_handler_seconds{method="chat.history"}. The host is shared, and the wide p99 ranges come from runs under other load, so the two blocks are also reported separately:

  • Block 2 (bench/block-b2/, started only below a 1-minute load of 12; arms at load 4 to 25): p99 at 1, 8, 16 and 32 clients 14.87 / 30.47 / 68.2 / 115.94 ms base vs 15.13 / 25.1 / 64.69 / 88.53 ms fix; p50 at 8 clients 18.11 vs 11.73 ms, throughput 431.6 vs 651.05 requests/s. At 16 clients p99 is about even while p50 drops from 35.98 to 24.6 ms.

  • Block 1 (bench/block-b1/, load 6 to 55): p50, throughput and queue wait improve at 8, 16 and 32 clients as above, but p99 does not improve consistently: 69.65 vs 73.11 ms at 8 clients, 147.19 vs 113.72 ms at 16, 198.87 vs 281.24 ms at 32. The worst fix tails are pg-head-r1 (the highest 1-minute load in the bench, 37 to 55) and pg-head-r2 (load 25 to 33, started with 25% of host memory free); the other two fix runs in the block have p99 21.7 and 36.16 ms at 8 clients. When the host's CPU is already saturated, extra workers add little.

  • Moved the wrong way: memory and backends (see User Impact: +120 MiB peak transcript heap, +388 MiB peak RSS, +219 MiB RSS 100 s after load, +2 peak backends); single-client p99 15.08 to 17.07 ms over all runs (14.87 to 15.13 ms in block 2; p50 6.09 to 6.00 ms over all runs, 5.71 to 5.94 ms in block 2; single-client p95 10.69 to 11.02 ms over all runs) and 19.35 to 33.27 ms in block 1 (driven by pg-head-r2, single-client p99 106.71 ms); single-client throughput 156.4 to 154.4 requests/s over all runs (163.6 to 155.65 in block 2); and in block 1, under the heaviest host load, p99 at 8 clients 69.65 to 73.11 ms and at 32 clients 198.87 to 281.24 ms. In the pair bench on current main, single-client p95 12.75 vs 10.47 ms (+22%), p99 21.33 vs 12.85 ms and throughput 136.4 vs 159.0 calls/s (-14%) (pair-bench/medians.tsv). These are part of the decision above.

  • Memory and connections (bench/block-all/memory-medians.tsv, per run in memory.tsv): see User Impact. Heap and isolate counts come from the Gateway's worker metrics, sampled by the 30 s diagnostic heartbeat; RSS and backend counts are sampled every 2 s.

  • SQLite: the lane size is unchanged by construction (the resolver returns the existing reader size for every non-PostgreSQL agent engine; covered by the sizing table and lane test). The earlier bench on 31866655fd6 measured SQLite p50, throughput and transcript isolates unchanged; not re-measured here.

  • Cap of four vs eight (earlier bench on 31866655fd6, 3 runs each, bench/medians.tsv and bench/memory-medians.tsv at the branch root, rows base-a, fix4 and fix8): eight gave 0.07 ms queue wait at 8 clients and 1.66 ms at 16, at +325 MiB peak transcript heap, +974 MiB peak RSS and 27 peak backends over base-a, against +120 MiB heap, +382 MiB RSS and 25 peak backends for four (fix4 over base-a).

  • Pair bench on current main 82210a2bbdb0 (pair-bench/): four builds from one main (main, main + improve(postgres): read each chat history page from one database snapshot #190001, main + this PR, main + both), four runs each in interleaved order, PostgreSQL 17.11, closed-loop chat.history at 1, 8, 16 and 32 clients. Gate results on the same main: unit 12 files / 162 tests pass with this PR (the new sizing and lane tests fail on plain main); with both PRs unit 28 / 386 and PostgreSQL conformance 15 / 165 pass. Medians of 4 runs, this PR vs main: at 8 clients p50 13.84 vs 19.65 ms, p99 26.26 vs 46.48 ms, 555 vs 385 calls/s, queue wait per worker request 1.06 vs 5.28 ms; at 16 clients p50 29.21 vs 41.94 ms, 507 vs 362 calls/s; at 32 clients p50 58.09 vs 79.41 ms, p99 88.81 vs 199.78 ms, 545 vs 372 calls/s. At 1 client p50 is 6.31 vs 6.01 ms and p99 is noisier (12.12 to 60.43 ms across runs vs 11.74 to 23.23 ms on main; the two highest runs had the highest arm-start load of this build's four runs, 13.1 and 17.9 in pair-bench/arms.tsv). Cost: peak Gateway RSS 2789 vs 2468 MiB (+321 MiB), peak transcript worker heap 456 vs 332 MiB (+124 MiB), peak transcript workers 8 vs 6, peak PostgreSQL backends 23 vs 21; 100 s after load, 4 workers vs 3 and the same 13 backends. With improve(postgres): read each chat history page from one database snapshot #190001 as well, p50 is the same at 16 and 32 clients (29.57 and 58.06 ms) but p99 is higher (81.27 vs 67.81 ms, 128.55 vs 88.81 ms). At 8 clients the pair has p50 15.21 ms, p99 55.06 ms and 480.2 calls/s: p99 is above this PR alone (26.26 ms) and also above main (46.48 ms), and throughput is below this PR alone (555.25 calls/s) in all four paired runs (arms.tsv), so host load does not explain it. The cost comes from improve(postgres): read each chat history page from one database snapshot #190001 on this dense-page store (history worker time per request 3.741 vs 3.229 ms at 8 clients, pair-bench/worker-time.tsv) and is reported there.

Gaps

  • The bench store is synthetic, written through the Gateway's own RPCs, because main does not admit a pg_restore of a production store. Its shape follows the production bench in [Feature]: chat.history on PostgreSQL queues behind two history workers under concurrent reads #188956.
  • Shared host: the p99 tails in block 1 are dominated by other load (per-arm load in arms.tsv). Two fix runs (pg-head-r2 in block 1, pg-head-r8 in block 2) started while another job held most host memory; both are kept.
  • At 16 clients and above the four-worker lane queues again (6.73 ms per worker request at 16, 17.02 ms at 32). A cap of eight removes most of that at a higher memory cost.
  • Memory figures needed one measurement-only line, applied identically to both builds: the diagnostic heartbeat publishes its memory sample every 30 s instead of only after agent activity (scripts/instrument-*.diff). Isolate counts and heap cover every transcript lane, not only history, and 30 s sampling can miss the exact peak. RSS was watched for 100 s after load here; the earlier 300 s pair on 31866655fd6 (bench/runs/pg-*-idle-r1 at the branch root) showed no lasting RSS difference with the same isolate count (1,676 vs 1,745 MiB at 300 s).
  • Transcript search on PostgreSQL also blocks on bridge replies and keeps its two-worker cap; not measured here.
  • The bench host is shared (1-minute load 4.2 to 13.8 at run start, pair-bench/run-order-and-load.txt, and 3.8 to 22.2 at arm start, pair-bench/arms.tsv). Tails at 1 and 8 clients move with that load; medians at 8 or more clients do not. Idle retirement past 100 s was not sampled in the pair bench; the earlier bench above covers it.

- PostgreSQL history workers spend most of a request blocked on bridge
  replies, so the shared two-worker reader cap queued concurrent
  chat.history requests while CPU sat idle.
- History on PostgreSQL agent stores now uses two workers per CPU above
  one, capped at four. SQLite and unset engines keep the reader size.
- The history pool resolves its size on first use, because boot installs
  the database engine after the lane module is imported.
- Transcript search and the other transcript lanes are unchanged.
- Tests: per-engine sizing table, and a lane test that installs the
  engine after import (PostgreSQL 4, SQLite 2).
- Docs: runtime architecture sizing note and the PostgreSQL backend
  budget.
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Nov 1, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: ready, awaiting a maintainer decision.

What this changes

This PR raises PostgreSQL history capacity to at most four workers and resolves its size after boot selects the database engine.

Example: Eight clients concurrently load chat.history from PostgreSQL in the supplied interleaved benchmark.

  • Before: Median p99 was 54.31 ms with peak transcript-worker heap of 334.1 MiB.
  • After: Median p99 was 31.76 ms with peak transcript-worker heap of 453.6 MiB.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong production-path evidence and no actionable patch defect; overall readiness is capped by the unresolved default-budget decision, and exact-head CI is not complete.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Inspected pinned artifacts exercise chat.history through built Gateways and real PostgreSQL, showing latency, throughput, queueing, memory, backend counts, and idle recovery; the four-build comparison includes the now-merged snapshot change, and shared-host limitations and executing revisions are disclosed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Conversation history loads more slowly when several PostgreSQL clients read concurrently.
Reason: The narrowed queueing request is covered, but revising an intentional resource-budget default requires owner acceptance of the disclosed tradeoff.

Merge readiness

⏳ Ready, awaiting maintainer decision

Keep open: this PR provides a distinct, measured concurrency improvement, with no actionable patch defects found; accepting the higher PostgreSQL history resource budget remains an owner decision.

Priority: P2
Reviewed head: 3e55cf3ef6807b9c15e6bcb46d7c686c604d06f6
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should PostgreSQL history default to at most four workers despite the measured memory, backend, and adverse latency costs?
  • Recommendation: Accept the four-worker exception: Approve the PostgreSQL-only increase for improved concurrent history throughput, accepting the disclosed memory, connection, and latency costs.
  • Why: The two-worker limit is intentional, and the inspected benchmarks establish the tradeoff without establishing owner acceptance of this PR's change.

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway history requests enter the foreground transcript pool, whose workers read the selected agent database and return history pages; existing resource owners retain admission, cleanup, and retirement.

flowchart LR
  A[History clients] --> B[Gateway history RPC]
  B --> C[History worker pool]
  D[Boot engine selection] --> C
  C --> E[Transcript workers]
  E --> F[PostgreSQL bridge]
  F --> G[Agent database]
Loading

Technical review

Best possible solution:

Adopt the bounded PostgreSQL-only history exception through the existing sizing and lifecycle owners if the owner accepts its measured resource cost.

Do we have a high-confidence way to reproduce the issue?

Current-main source retains the two-worker bottleneck, and inspected contributor artifacts reproduce it through real Gateway RPCs on documented recent revisions; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch is a focused capacity improvement using existing owners; first-use construction correctly accommodates boot-time engine selection, and the paired snapshot benchmark confirms a distinct remaining throughput benefit.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 869734209368.

Provenance checked

  • Foreground reader budget changes intended behavior with a stated reason (48f3aa1: Bound resident and peak database/transcript isolate memory by extending the two-worker reader policy to history and search.)
  • Boot-selected database engine keeps the original intent (1e2d50c: Agent workers consume the immutable database engine selected during boot.)
  • Reader resource ownership keeps the original intent (0ee0def: Unify pending reads, native residency, revocation, and cleanup under the existing history database resource owner.)
  • Deferred history presentation keeps the original intent (07fcef0: Load presentation on demand or explicit prewarm rather than eagerly for every foreground worker.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 48f3aa1 adds src/infra/worker-pool-sizing.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 48f3aa1af0b7; files: src/infra/worker-pool-sizing.ts)
  • Vincent Koc: Raw commit eea1c93 adds src/config/sessions/session-transcript-worker-resources.ts:243 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: eea1c93a1d1c; files: src/config/sessions/session-transcript-worker-resources.ts)

PR surface

Source +40, Tests +117, Docs +5. Total +162 across 7 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 3 73 33 +40
Tests 2 117 0 +117
Docs 2 9 4 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 199 37 +162

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Concurrent PostgreSQL history loading has measured queueing and latency costs while requests continue returning correct results.
  • merge-risk: 🚨 other: The default increase trades additional worker memory and PostgreSQL backends for throughput, with disclosed adverse single-client and loaded-host latency measurements.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-01T07:14:07.385Z sha 9873480 :: blocked before merge. :: none
  • reviewed 2026-11-07T23:22:03.084Z sha 9873480 :: blocked before merge. :: none
  • reviewed 2026-11-11T15:51:32.900Z sha 9873480 :: blocked before merge. :: none
  • reviewed 2026-11-11T17:51:53.741Z sha 9873480 :: ready, awaiting a maintainer decision. :: none

Reviewed November 16, 2026, 2:04 PM ET / 19:04 UTC (Revision 5).

@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 4, 2026
etzelm added a commit to etzelm/openclaw that referenced this pull request Nov 7, 2026
@etzelm

etzelm commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

No code change. The bench is re-run on current main (078033289a3) against this head merged into it, on the final commit: 8 interleaved runs per build at 1, 8, 16 and 32 clients, all runs kept. At 8 clients p99 drops from 54.31 to 31.76 ms and queue wait per worker request from 5.57 to 1.23 ms; peak transcript heap rises from 334.1 to 453.6 MiB and peak backends from 23 to 25. The body now states the decision on the history worker cap with options and a recommendation, the acceptance rule, and every metric that moved the wrong way.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

etzelm added a commit to etzelm/openclaw that referenced this pull request Nov 11, 2026
@etzelm

etzelm commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

No code change. Rebuilt and retested on current main (82210a2bbdb0), alone and together with #190001, and the body now has the pair benchmark of both changes on one main.

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@etzelm

etzelm commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

No code change. #188956 is now trimmed to the history worker sizing, so this PR closes it. The per-page snapshot part moved to #197313, addressed by #190001.

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@etzelm

etzelm commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@VACInc
VACInc merged commit a079190 into openclaw:main Nov 18, 2026
202 of 204 checks passed
@VACInc

VACInc commented Nov 18, 2026

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…0129)

- PostgreSQL history workers spend most of a request blocked on bridge
  replies, so the shared two-worker reader cap queued concurrent
  chat.history requests while CPU sat idle.
- History on PostgreSQL agent stores now uses two workers per CPU above
  one, capped at four. SQLite and unset engines keep the reader size.
- The history pool resolves its size on first use, because boot installs
  the database engine after the lane module is imported.
- Transcript search and the other transcript lanes are unchanged.
- Tests: per-engine sizing table, and a lane test that installs the
  engine after import (PostgreSQL 4, SQLite 2).
- Docs: runtime architecture sizing note and the PostgreSQL backend
  budget.
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…law#194384)

* docs: clarify PostgreSQL conformance coverage

* fix(cron): keep one-shot finalization working on PostgreSQL 16

* test(database): reuse cron conformance for JSON conversion regression

* test(postgres): accept fractional explain row counts

(cherry picked from commit 7ab0143)

Release adaptation: Only engine-owned jsonValue and retained cron enabled JSON replacement; preserve native boolean type with PG16 explicit ::json and SQLite json(). Omit unrelated PG docs/EXPLAIN test edits; retained one-shot enabled-transition caller present on baseline.

Follow-up dispositions: e029e18 docs: document isolated PostgreSQL restore drills (openclaw#202704); 49f0740 fix(database): report disabled memory after a port (openclaw#202630); a80b564 fix: keep database workers healthy after silent connection loss (openclaw#201856); 3d91af2 fix(config): reject reserved PostgreSQL schema prefixes (openclaw#202097); 835d722 fix: catch incompatible ownership before porting to SQLite (openclaw#202101); 67796a6 fix: keep scheduled Git backups current on PostgreSQL (openclaw#201870); cc849dd fix: recover lease heartbeats after a PostgreSQL connection loss (openclaw#201858); 6594caf fix: prepare macOS runtime pins without the PostgreSQL secret (openclaw#202102); 6ca56cd docs: clarify PostgreSQL storage and backup coverage (openclaw#202086); a079190 fix(postgres): chat history slows under concurrent reads (openclaw#190129); 2ff4256 feat(database): keep PostgreSQL rollback captures in PostgreSQL (openclaw#196236); 96c685b feat(backup): restore PostgreSQL stores into a staging database for restore drills (openclaw#194808); fb83d65 fix: reduce transcript allocation when preparing native context seeds; 71ec4d2 fix(config): keep Workboard PostgreSQL upgrades readable (openclaw#194648); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682)

Validation: Baseline cron generated json(bound text) on PostgreSQL where json(text) is unavailable; helper and focused boolean regression retained. Exact PostgreSQL16 server proof unavailable; focused SQLite/helper tests queued. diff check passed.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 38fdd9b52704d588d9ca24ef8e391d644961c985)
(cherry picked from commit fb935e6912388314851b05cb698ef038b83bbd07)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: chat.history on PostgreSQL queues behind two history workers under concurrent reads

3 participants