Skip to content

perf: move cancellation token futures outside Client::run loop - #1914

Draft
jkaczman wants to merge 2 commits into
mainfrom
jk-client-run-cancellation-futures
Draft

jkaczman wants to merge 2 commits into
mainfrom
jk-client-run-cancellation-futures

Conversation

@jkaczman

@jkaczman jkaczman commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Previously, we were undergoing a lot of unnecessary overhead by awaiting on the admin termination (FORCE_RELOAD) and shutdown cancellation futures WITHIN (on every iteration of) our Client::run loop.

This reduces the overhead by placing these awaits on our cancellation token futures within a select! above the loop, so that we only await these futures a singular time per instance of Client::run (vs. every loop iteration).

Local flamegraph shows this reduces our total overhead by about 1-2%.

Arm64 and x86 benchmarks show a 4% increase in TPS when dealing with 8 workers.

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/frontend/client/mod.rs 91.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jkaczman
jkaczman marked this pull request as draft October 28, 2026 17:26
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Metal bench (arm64) passed. All 148 measures within bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn ctx/txn
pooler 26.26 (-0.2% ± 0.8%) 26,147 (-1.0% ± 0.8%) 34,808 (-1.1% ± 0.02%) 38,096 (+0.7% ± 1.3%)
lb 27.06 (-1.0% ± 1.3%) 27,352 (-2.0% ± 1.1%) 35,681 (-1.0% ± 0.03%) 38,652 (-0.4% ± 1.7%)
sharding-w2 48.48 (-2.7%) 62,140 (-3.1%) 70,975 (-1.8%) 58,013 (-2.3%) 1.397 (+0.3%)
sharding-w8 165,399 (+3.9%) 43.77 (-4.8%) 62,456 (-6.2%) 54,846 (-2.2%) 50,356 (-3.1%) 0.1624 (+8.1%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 12,109 (-0.2% ± 1.8%) 3,033 (-0.7% ± 0.7%) 2,722 (-4.7% ± 1.3%)
lb 12,742 (-2.6% ± 2.4%) 3,119 (-1.3% ± 0.8%) 2,996 (-3.2% ± 1.7%)
sharding-w2 34,299 (-4.0%) 4,996 (-3.6%) 6,815 (+1.0%)
sharding-w8 34,289 (-9.3%) 4,732 (-4.9%) 9,412 (+0.3%)

Microbench: all 135 measures within bounds.

lb flamegraph vs 97fc159

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs 97fc159

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs 97fc159

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs 97fc159

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs 97fc159

sharding-w8

Open interactive for hover, zoom and search.

sharding-w8 removed

Open interactive.

Logs

lb, microbench, pooler, sharding-w2, sharding-w8, verdict.json

Compared d75b48c with 97fc159 on c7g.metal (on-demand).

@jkaczman
jkaczman force-pushed the jk-client-run-cancellation-futures branch from 58a59f5 to d75b48c Compare October 28, 2026 22:11
@github-actions

Copy link
Copy Markdown
Contributor

Metal bench (x86) failed. 1 of 148 measures outside bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn ctx/txn
pooler 25.92 (-0.8% ± 0.2%) 19,922 (-2.8% ± 0.1%) 36,447 (-0.9% ± 0.02%) 33,507 (+0.2% ± 0.4%)
lb 26.29 (-0.9% ± 0.1%) 20,510 (-2.7% ± 0.1%) 37,392 (-0.9% ± 0.02%) 33,575 (-0.0% ± 0.3%)
sharding-w2 40.25 (-2.7%) 43,581 (-3.5%) 74,518 (-1.7%) 39,320 (-3.0%) 1.519 (+0.4%)
sharding-w8 176,865 (+3.9%) 38.03 (-2.5%) 48,100 (-2.1%) 57,707 (-2.3%) 41,501 (-3.1%) 0.1865 (-0.1%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 3,222 (-7.2% ± 0.3%) 1,133 (-3.4% ± 0.5%) 41,667 (-2.0% ± 0.2%)
lb 3,323 (-6.6% ± 0.4%) 1,149 (-3.8% ± 0.5%) 43,167 (-2.1% ± 0.4%)
sharding-w2 5,668 (-11.7%) 1,610 (-5.4%) 119,262 (-1.4%)
sharding-w8 3,213 (-8.7%) 972 (-4.0%) 183,988 (-0.9%)
benchmark measure result baseline change bound
extended_cached::delete_by_key latency 2,875 2,727 +5.42% ± 0.93% +5%

Microbench: 134 of 135 measures within bounds.

  • extended_cached: 15 of 15 benches slower, median +3.0% ± 0.8%
  • extended_cold: 13 of 15 benches slower, median +1.4% ± 0.7%
  • simple_cold: 13 of 15 benches slower, median +1.7% ± 0.5%
lb flamegraph vs 97fc159

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs 97fc159

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs 97fc159

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs 97fc159

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs 97fc159

sharding-w8

Open interactive for hover, zoom and search.

sharding-w8 removed

Open interactive.

Logs

lb, microbench, pooler, sharding-w2, sharding-w8, verdict.json

Compared d75b48c with 97fc159 on c7i.metal-48xl (spot).

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant