Skip to content

refactor: move ReadyForQuery and CommandComplete handling into their own methods - #2025

Open
jkaczman wants to merge 1 commit into
mainfrom
jk-refactor-rfq-cc-move
Open

jkaczman wants to merge 1 commit into
mainfrom
jk-refactor-rfq-cc-move

Conversation

@jkaczman

Copy link
Copy Markdown
Contributor

Previously,

  • Server::read and QueryEngine::process_server_message handled ReadyForQuery and CommandComplete inline
  • MessageBuffer::read read from the stream and split off the message in a singular function

Now, the handling is in separate methods. No behavior change.

Motivation for this is to re-use the logic in a follow-up PR

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.50943% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/frontend/client/query_engine/query.rs 90.62% 6 Missing ⚠️
pgdog/src/backend/server.rs 91.89% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

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

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn kernel instr/txn ctx/txn
pooler 19.07 (+0.7% ± 1.5%) 18,340 (+0.2% ± 0.7%) 32,118 (+0.2% ± 0.02%) 30,473 (+1.2% ± 2.8%) 51,043 (-0.3% ± 0.5%)
lb 19.58 (+0.6% ± 1.0%) 18,944 (-0.0% ± 0.8%) 33,012 (+0.2% ± 0.05%) 30,972 (+1.5% ± 2.0%) 52,180 (+0.1% ± 0.5%)
sharding-w2 32.01 (+2.0% ± 1.1%) 43,417 (+1.6% ± 1.8%) 97,608 (+0.2% ± 0.04%) 39,670 (+3.0% ± 2.7%) 53,668 (-0.0% ± 0.08%) 1.548 (-0.2% ± 0.4%)
sharding-w8 246,226 (-0.7% ± 1.6%) 29.13 (+1.1% ± 1.3%) 44,504 (+1.0% ± 0.10%) 53,124 (+0.3% ± 0.09%) 35,956 (+1.2% ± 2.9%) 42,314 (-0.1% ± 0.09%) 0.1658 (-2.5% ± 0.7%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 7,699 (-0.6% ± 2.0%) 2,639 (+0.0% ± 0.7%)
lb 8,045 (-0.8% ± 1.8%) 2,699 (-0.1% ± 0.7%)
sharding-w2 17,093 (+4.7% ± 4.6%) 4,005 (+2.6% ± 3.2%)
sharding-w8 19,332 (+3.9% ± 0.9%) 3,961 (+2.2% ± 1.2%)

Microbench: all 504 measures within bounds.

Hot code per txn
path base head change
pooler 112.9 KB 112.5 KB -0.4 KB
sharding-w2 165.0 KB 166.4 KB +1.4 KB

pooler:

crate base head change
pgdog::frontend::client::query_engine 19.3 KB 19.7 KB +0.4 KB
tokio 18.5 KB 18.4 KB -0.1 KB
pgdog::backend::pool 17.7 KB 17.6 KB -0.1 KB
aws-lc (TLS crypto) 10.8 KB 10.6 KB -0.2 KB
rustls (TLS) 8.4 KB 8.3 KB -0.1 KB
pgdog::frontend (other) 7.8 KB 7.9 KB +0.1 KB
pgdog::backend::server 7.2 KB 7.5 KB +0.2 KB
other 6.4 KB 6.6 KB +0.1 KB
everything else 16.7 KB 15.9 KB -0.8 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 5.6 KB +0.2 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 5.1 KB +0.0 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 4.1 KB +0.1 KB
tokio::runtime::task::raw::poll 3.3 KB +0.2 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 3.2 KB +0.4 KB

sharding-w2:

crate base head change
pgdog::frontend::router 28.9 KB 29.1 KB +0.2 KB
pgdog::frontend::client::query_engine 20.6 KB 20.9 KB +0.2 KB
tokio 18.8 KB 19.1 KB +0.3 KB
pgdog::backend::pool 18.2 KB 18.4 KB +0.2 KB
aws-lc (TLS crypto) 13.2 KB 12.8 KB -0.4 KB
other 9.4 KB 9.7 KB +0.2 KB
pgdog::frontend (other) 8.6 KB 8.9 KB +0.2 KB
pgdog::backend::server 7.9 KB 8.1 KB +0.2 KB
everything else 39.3 KB 39.4 KB +0.1 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 6.3 KB +0.2 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 5.1 KB +0.1 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 4.1 KB +0.1 KB
tokio::runtime::task::raw::poll 3.3 KB +0.1 KB
pgdog::frontend::router::parser::query::select::<impl pgdog::frontend::router::parser::que 3.3 KB +0.0 KB
lb flamegraph vs e9316d2

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs e9316d2

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs e9316d2

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs e9316d2

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs e9316d2

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 3625258 with e9316d2 on c8g.metal-24xl (spot).

@github-actions

Copy link
Copy Markdown
Contributor

Metal bench (x86) passed. All 517 measures within bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn kernel instr/txn ctx/txn
pooler 25.9 (+0.1% ± 0.2%) 18,872 (+0.5% ± 0.3%) 34,034 (+0.0% ± 0.07%) 33,560 (+0.0% ± 0.3%) 36,523 (+0.2% ± 0.5%)
lb 26.3 (+0.2% ± 0.3%) 19,433 (+0.8% ± 0.1%) 34,995 (+0.0% ± 0.08%) 33,634 (-0.3% ± 0.7%) 37,177 (-0.3% ± 0.6%)
sharding-w2 42.31 (+0.8% ± 2.9%) 47,981 (+1.9% ± 5.1%) 101,476 (+0.1% ± 0.07%) 38,446 (+0.1% ± 1.8%) 40,214 (-0.1% ± 0.5%) 1.523 (-0.4% ± 0.8%)
sharding-w8 208,029 (+0.2% ± 0.4%) 32.78 (-0.1% ± 0.2%) 45,783 (-0.1% ± 0.7%) 55,762 (+0.1% ± 0.00%) 31,146 (-0.3% ± 0.7%) 32,493 (+0.0% ± 0.04%) 0.1716 (-0.2% ± 0.8%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 3,511 (+5.8% ± 1.2%) 1,161 (+1.3% ± 1.2%) 37,225 (-2.5% ± 0.5%)
lb 3,661 (+7.0% ± 0.4%) 1,185 (+1.4% ± 0.6%) 38,226 (-2.6% ± 0.3%)
sharding-w2 7,340 (+22.2% ± 58.9%) 1,637 (+2.8% ± 5.4%) 110,886 (-3.0% ± 7.6%)
sharding-w8 3,264 (+3.1% ± 1.9%) 966 (-0.6% ± 2.5%) 174,208 (-0.5% ± 1.0%)

Microbench: all 504 measures within bounds.

Hot code per txn
path base head change
pooler 111.6 KB 111.9 KB +0.4 KB
sharding-w2 165.4 KB 164.8 KB -0.6 KB

pooler:

crate base head change
pgdog::frontend::client::query_engine 21.1 KB 21.7 KB +0.6 KB
tokio 18.2 KB 18.5 KB +0.2 KB
pgdog::backend::pool 18.8 KB 18.1 KB -0.7 KB
pgdog::frontend (other) 9.2 KB 9.1 KB -0.1 KB
aws-lc (TLS crypto) 8.9 KB 8.9 KB +0.0 KB
rustls (TLS) 7.7 KB 7.9 KB +0.2 KB
pgdog::backend::server 6.9 KB 7.5 KB +0.6 KB
other 6.1 KB 5.9 KB -0.1 KB
everything else 14.6 KB 14.2 KB -0.4 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 6.9 KB -0.1 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 6.3 KB +0.1 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 5.0 KB +0.2 KB
tokio::runtime::task::raw::poll 3.7 KB +0.0 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 3.3 KB +0.0 KB

sharding-w2:

crate base head change
pgdog::frontend::router 28.8 KB 29.4 KB +0.6 KB
pgdog::frontend::client::query_engine 22.8 KB 22.8 KB +0.0 KB
pgdog::backend::pool 18.6 KB 18.3 KB -0.3 KB
tokio 18.5 KB 18.2 KB -0.3 KB
pgdog::frontend (other) 10.4 KB 10.5 KB +0.1 KB
aws-lc (TLS crypto) 10.8 KB 10.4 KB -0.4 KB
other 10.4 KB 10.1 KB -0.3 KB
pgdog::backend::server 7.7 KB 8.3 KB +0.6 KB
everything else 37.4 KB 36.8 KB -0.6 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 7.9 KB +0.1 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 6.2 KB -0.1 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 4.6 KB -0.1 KB
pgdog::frontend::router::parser::query::select::<impl pgdog::frontend::router::parser::que 4.5 KB +0.2 KB
tokio::runtime::task::raw::poll 3.9 KB -0.1 KB
lb flamegraph vs e9316d2

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs e9316d2

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs e9316d2

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs e9316d2

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs e9316d2

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 3625258 with e9316d2 on m7i.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