Repository navigation
Conversation
rmcdaniel
force-pushed
the
general/server-1372-two-read-slots
branch
from
November 26, 2026 18:52
74d3684 to
ebd5dc5
Compare
…eady, and pace idle reads With one node-wide read slot, held polls' reads queued behind each other at production poll counts (Server #1372). Five connections: a node now opens a request pool of four plus the maintenance connection, so held polls' reads take two slots, the transition queue's holder one more, and producers and registrations keep the last connection. DW_WORKER_LONG_POLL_RESERVED_HTTP_WORKERS=2 leaves two probe permits. Statement cache: the maintenance connection keeps at most 48 prepared statements (none when the cache is off), through a backend hook and a new get_statement_cache_capacity getter on both vendored drivers' connect options, so the request connections keep 192 by default: above the #1174 working set (166) and within MySQL's default max_prepared_stmt_count at 20 nodes (20 x (4 x 192 + 48) = 16320). The capacity bound becomes 4083. The hot-path qualifications run 180 statements again. Per-queue wakes: one Notify woke every held poll on the node at every commit. A transaction now records the namespace and queue of each ready task create_task_dispatched creates and its commit wakes only those queues' held workflow and activity polls (poll_wakes.rs). Starts, signals and workflow and activity task completions wake those queues (a completion also its run's queue, whose other tasks it unfences) and the waiters that are not held worker polls (query-task polls, update, query and validation result waits), instead of every poll; every other commit still wakes everyone. A missed wake costs latency until the next timed read, never a task. Idle-read pacing: a held poll's timed reads back off to a ceiling that grows with the polls waiting on the node (250 ms up to 31, then 8 ms each, at most 2 s), and no pause is shorter than a quarter of it. A held poll's later probes check its queue for abandoned workflow task leases at most once a second per queue per node; every poll's first probe still checks. Those checks were about half of all held-poll reads with many idle polls. Harnesses: runtime::mysql::held_poll_bench (8, 64 and 256 held polls with producers, reporting read-slot waits, poll answer and dispatch latency and start throughput) and tests/execution/hot_path_cache.rs (statement cache prepares, closes and hit rate per workflow), both ignored benchmarks. Docs: capacity and the reserved-connection mapping, the statement cache default, bound and formula (server reference, rust README). The Helm chart's README and UPGRADING change when a chart release pairs with the server release that includes this, as chart changes require a chart version bump. Part of #1372. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rmcdaniel
force-pushed
the
general/server-1372-two-read-slots
branch
from
November 26, 2026 18:55
ebd5dc5 to
048b36c
Compare
|
Member
Author
|
Held, not merged (General). At
The measured cause is the serialized transition queue saturating at about 130 transitions/s. Each idle poll's first probe claims under the lock (PHP parity), and the 2 s bench polls make that roughly one claim per cycle. Deciding needs either a benchmark with SDK-typical poll timeouts (20–55 s) or a decision on the first-probe claim (options in the description). The later-probe fix was split out and merged as #1380. |
This branch has not been deployed
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.



Part of #1372.
General decided "yes" on #1372: add a fifth pool connection. This PR does that and addresses the review of head
74d3684a. The targets are only partly met. The Evidence section has the numbers and the reason.The later-probe slot-wait fix was split out to #1380 at review, so this PR no longer contains it.
Change
Five connections.
POOL_CONNECTIONSgoes from 4 to 5: a request pool of 4 plus the maintenance connection.DW_WORKER_LONG_POLL_RESERVED_HTTP_WORKERS=2leaves two probe permits.Split statement-cache budget (review item 2a).
Backend::maintenance_connect_options, used whereStore::with_maintenance_poolopens that pool.get_statement_cache_capacitygetter on both vendored drivers' connect options (documented inDURABLE-PATCH.md).MEASURED_WORKING_SET = 166, restored) and fits the 20-node budget: 20 × (4 × 192 + 48) = 16320 ≤ 16382.MAXis now 4083, the largest value that keeps one node within the default limit.Per-queue poll wakes (
poll_wakes.rs).Notifywoke every held poll on the node at every commit.create_task_dispatchedcreates, and its commit wakes only those queues' held workflow and activity polls.Idle-read pacing (review item 3).
Harnesses committed (review item 4).
runtime::mysql::held_poll_bench(mysql_held_poll_bench.rs): ignored benchmarks for 8, 64 and 256 held polls, withcfg(test)read-slot wait statistics inprobe_connections.rs.tests/execution/hot_path_cache.rs: an ignored statement-cache measurement. It reports prepares, closes and hit rate from the server'sCom_stmt_*counters, and per-connection cached statements whenperformance_schemais on. The per-route hit rates in the first revision came from a scratch hook in the vendored driver that is not committed.Docs.
docs/server-reference.md: capacity, the reserved-connection mapping, and the statement cache row. It cites Serve high held-poll counts without a single node-wide probe read slot #1372 for about 126 statements and Native: hot-path statements exceed sqlx's statement cache, causing prepare/close churn #1174 for about 166 on the PHP SDK workload.rust/README.md: the cache section, the formula, and the "Four connections" line.Chart.yaml.versionbump for any change underk8s/helm/durable-workflow.README.mdandUPGRADING.mdneed the text below.Release note
DW_NATIVE_DB_STATEMENT_CACHE_CAPACITY(request connections) now defaults to 192, down from 200, and accepts up to 4083, down from 4095. The maintenance connection keeps at most 48.nodes × (4 × capacity + min(capacity, 48)) + other clients ≤ max_prepared_stmt_count; that allows 20 nodes at the default.DW_WORKER_LONG_POLL_RESERVED_HTTP_WORKERS=2leaves two probe permits.For the chart release that pairs with this server change
In
k8s/helm/durable-workflow/README.md, under "Native capacity and storage", replace the first bullet:Add this to
docs/UPGRADING.mdfor that release:Evidence
Statement cache at the default (committed harness, MariaDB 10.11 with
performance_schemaon): 2.52 prepares and 0 closes per workflow, 99.71 % hit rate (200 workflows). At the end, the cached statements were 8 on the maintenance connection and 124, 126, 149 and 160 on the four request connections: all within 192, and the largest exactly at the 160 the first revision proposed.From the first revision's capacity sweep (same workload; per-connection working set 123 to 126):
Held polls, with the committed harness.
d41c85f3, with 4 request connections and 3 read slots.c4c89b35, which includes Keep registrations and producers answering through database stalls #1358: 3 request connections, 1 read slot.pool_timeout/ poll errorsAgainst the targets:
pool_timeouts and no poll errors in any run.Why producers are worse.
The transition queue at 256 polls. Measured with scratch counters (
ReadPacereturns by cause) and the totals above.Read concurrency at 64 polls. The queue is not saturated here (about 57–61 transitions/s), and this branch makes about the same number of reads as main (6.6k against 6.9k) with almost no read-slot waiting.
The benchmark's 2 s polls. They multiply the per-cycle costs. Per cycle these are: admission, the first probe's claim, and the abandoned-lease check. SDK-typical 20–55 s polls amortise those 10–25×.
Options, not done here so as not to change claim semantics or tune silently:
Other tests
poll_wakes:execution::poll_wake_tests::hot_commits_wake_the_queues_they_make_ready: a SQLite runtime. A start, a workflow task completion that schedules an activity on another queue (that queue and the run's own are woken), an activity completion and a signal each wake exactly the expected queues. The signal is shown to have made the run's task ready.poll_readiness::the_timed_read_ceiling_grows_with_waiting_polls_within_bounds.backend::maintenance_cache_tests::the_maintenance_connection_keeps_a_small_cache_or_nonefor MySQL and PostgreSQL, including capacity 0.statement_cache: the bound, the defaults and the per-node total.803ef851(Bound silent database peers during release and in-flight statements #1375):803ef851:Trade-offs
🤖 Generated with Claude Code