Skip to content

perf: remove redundant per-statement clock reads (6 -> 3) - #1890

Merged
jkaczman merged 1 commit into
mainfrom
jk-one-clock-read
Oct 23, 2026
Merged

jkaczman merged 1 commit into
mainfrom
jk-one-clock-read

Conversation

@jkaczman

Copy link
Copy Markdown
Contributor

Reduces clock reads per statement from six to three.

Now we:

  • Re-use the request's arrival time to set the transaction start time
  • Only compute the buffered-request elapsed time when debug logging is enabled
  • Skip the clock read when the server transitions to Active right after checkout, since checkout already started the query and transaction timers

The remaining three are from request arrival, pool checkout, and ReadyForQuery.

Re #1877

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.11628% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/frontend/client/mod.rs 31.25% 11 Missing ⚠️
pgdog/src/frontend/client/query_engine/query.rs 66.66% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Metal bench passed. All 150 measures within bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn ctx/txn
pooler 28.38 (+0.8% ± 1.0%) 29,497 (+0.8% ± 1.5%) 35,348 (-1.2% ± 0.02%) 38,295 (+0.8% ± 1.3%)
lb 29.25 (+0.5% ± 0.7%) 30,937 (+0.6% ± 0.8%) 36,215 (-1.2% ± 0.03%) 38,958 (+0.4% ± 1.4%)
sharding-w2 53.04 (+0.6%) 70,043 (+1.7%) 72,609 (-0.6%) 59,664 (-1.3%) 1.399 (-0.1%)
sharding-w8 156,287 (+1.4%) 46.9 (-1.6%) 68,399 (-2.1%) 56,300 (-0.7%) 52,456 (-1.1%) 0.1461 (+2.1%)
Counters per txn
suite br mispred l1i refill backend stall
pooler 79.58 (-2.9% ± 2.5%) 3,427 (+1.5% ± 1.3%) 2,337 (-6.2% ± 1.9%)
lb 85.02 (-1.4% ± 1.4%) 3,510 (+0.9% ± 0.7%) 2,497 (-6.2% ± 2.4%)
sharding-w2 329 (+4.8%) 5,614 (+2.0%) 6,168 (-7.5%)
sharding-w8 334 (+0.9%) 5,249 (+0.8%) 8,571 (-10.6%)

Microbench: all 135 measures within bounds.

  • simple_cold: 13 of 15 benches slower, median +2.3% ± 0.7%
lb flamegraph vs f5632bc

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs f5632bc

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs f5632bc

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs f5632bc

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs f5632bc

sharding-w8

Open interactive for hover, zoom and search.

sharding-w8 removed

Open interactive.

Logs

sharding-w2, sharding-w8, verdict.json

Compared 3f4737f with f5632bc.

@jkaczman
jkaczman merged commit d2adb1d into main Oct 23, 2026
67 of 68 checks passed
@jkaczman
jkaczman deleted the jk-one-clock-read branch October 23, 2026 21:16
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