Skip to content

fix(metrics): wait_time for pool calculation#836

Open
meskill wants to merge 1 commit intomainfrom
fix/wait_time_calculation
Open

fix(metrics): wait_time for pool calculation#836
meskill wants to merge 1 commit intomainfrom
fix/wait_time_calculation

Conversation

@meskill
Copy link
Contributor

@meskill meskill commented Mar 18, 2026

Unify wait_time and reads/counts.writes calculations on both paths (with pool waiting and without it).

I've run benchmarks from cli.sh to compare the changes against main branch.
image

A slight degradation could be noted, but I'd argue that the reason for it is that more operation are actually executed in order to provide true metrics since the old code was not updating read/writes on some paths and in another place improper elapsed calculations where not using Instant::now()

@levkk
Copy link
Collaborator

levkk commented Mar 18, 2026

A slight degradation could be noted, but I'd argue that the reason for it is that more operation are actually executed in order to provide true metrics since the old code was not updating read/writes on some paths and in another place improper elapsed calculations where not using Instant::now()

That's definitely not the case. I think you're actually witnessing the impact of calling Instant::now() in a hot path! Recording statistics has no impact on query flow order - pgbench is an application that collects its own metrics, so the metrics changes inside PgDog have no impact on what metrics pgbench will present.

Try running the benchmark a few times to get a more consistent result, it's definitely possible to see inconsistent numbers with pgbench because of CPU contention / Postgres / IO.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants