Skip to content

Investigate and eliminate PostgreSQL performance-test tail latency - #172

Merged
MisterVVP merged 6 commits into
mainfrom
dev-investigate-postgresql-concurrency-issues
Jul 26, 2026
Merged

MisterVVP merged 6 commits into
mainfrom
dev-investigate-postgresql-concurrency-issues

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Jul 25, 2026 •

Copy link
Copy Markdown
Owner

Motivation

PostgreSQL performance tests showed severe concurrency tail latency and little throughput improvement above concurrency 1.

Description

  • Add PostgreSQL phase diagnostics for connection acquisition, writes, listing, and transaction begin/commit.
  • Remove executor-wide request serialization that blocked otherwise independent operations.
  • Add deterministic concurrent task, push-config, pagination, and same-task history tests.
  • Add a consolidated postgres-tail performance profile with five repetitions, one-second warmup, and concurrency 1, 4, and 8.
  • Export per-run results, median aggregates, PostgreSQL phase timings, and query-plan evidence to JSON, CSV, and Markdown.

Results

For PushNotify_EndToEndManyConfigs at concurrency 4:

Metric #171 baseline Current median
Throughput 102.82 ops/s 166.52 ops/s
p95 160.85 ms 79.05 ms
p99 707.69 ms 260.17 ms
Max 1.94 s 0.41 s

The focused validation completed 150,000 operations with zero errors. The results identify executor-wide serialization as the primary bottleneck; connection-pool wait remained negligible and the relevant PostgreSQL indexes were confirmed.

Closes #171.

@MisterVVP MisterVVP added the codex Automatic label added by codex agent. Should not be used label Jul 25, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Jul 25, 2026
@MisterVVP MisterVVP added AI agent AI agent contribution and removed codex Automatic label added by codex agent. Should not be used labels Jul 25, 2026
@MisterVVP MisterVVP linked an issue Jul 25, 2026 that may be closed by this pull request
14 tasks
@MisterVVP

Copy link
Copy Markdown
Owner Author

Performance comparison

All rows below use the PostgreSQL in-process driver with 2,000 operations.

Original issue baseline versus latest run — concurrency 4

Scenario Metric #171 baseline Latest run Change
PushNotify_EndToEndManyConfigs Throughput 102.82 ops/s 294.66 ops/s +186.6%
p95 160.85 ms 25.80 ms -84.0%
p99 707.69 ms 67.43 ms -90.5%
Max 1,941.00 ms 99.43 ms -94.9%
PushConfig_CreateMany Throughput 204.00 ops/s 644.75 ops/s +216.1%
p95 5.70 ms 8.06 ms +41.4%
p99 6.95 ms 14.27 ms +105.3%
Max 9,803.59 ms 84.88 ms -99.1%
PushConfig_ListManyConfigs Throughput 1,427.41 ops/s 6,778.66 ops/s +374.9%
p95 0.77 ms 0.76 ms -1.9%
p99 0.80 ms 0.90 ms +11.5%
Max 1,400.84 ms 2.08 ms -99.9%
SendMessage_FollowUpExistingTask Throughput 106.47 ops/s 458.76 ops/s +330.9%
p95 62.14 ms 14.66 ms -76.4%
p99 64.06 ms 26.07 ms -59.3%
Max 127.42 ms 59.40 ms -53.4%
SendMessage_CreateTask Throughput 447.27 ops/s 1,581.89 ops/s +253.7%
p95 2.47 ms 3.16 ms +27.6%
p99 3.45 ms 6.52 ms +88.7%
Max 4,471.32 ms 21.61 ms -99.5%

Effect of removing executor-wide serialization

Scenario Metric Before lock removal After lock removal Change
PushNotify_EndToEndManyConfigs Throughput 93.38 ops/s 294.66 ops/s +215.5%
p95 15.70 ms 25.80 ms +64.4%
p99 1,065.89 ms 67.43 ms -93.7%
Max 6,011.98 ms 99.43 ms -98.3%
PushConfig_CreateMany Throughput 181.57 ops/s 644.75 ops/s +255.1%
p99 11.77 ms 14.27 ms +21.3%
Max 6,189.90 ms 84.88 ms -98.6%
PushConfig_ListManyConfigs Throughput 1,550.37 ops/s 6,778.66 ops/s +337.2%
p99 0.95 ms 0.90 ms -5.6%
Max 1,050.10 ms 2.08 ms -99.8%
SendMessage_FollowUpExistingTask Throughput 111.04 ops/s 458.76 ops/s +313.2%
p95 59.87 ms 14.66 ms -75.5%
p99 61.85 ms 26.07 ms -57.9%
Max 80.87 ms 59.40 ms -26.5%

Latest end-to-end scaling

Concurrency Throughput p50 p95 p99 Max
1 120.93 ops/s 7.23 ms 13.44 ms 26.59 ms 90.91 ms
4 294.66 ops/s 11.17 ms 25.80 ms 67.43 ms 99.43 ms

Concurrency 4 delivers 2.44× the concurrency-1 throughput.

Latest end-to-end PostgreSQL phase diagnostics — concurrency 4

Phase p95 p99 Max
Connection acquisition 0.004 ms 0.014 ms 0.136 ms
Task upsert 2.712 ms 18.617 ms 84.253 ms
Push-config upserts 9.272 ms 46.140 ms 91.690 ms
Push-config list 1.160 ms 1.366 ms 3.031 ms
Transaction begin 0.340 ms 0.416 ms 0.713 ms
Transaction commit 1.634 ms 9.668 ms 86.854 ms

The remaining operation tails are now attributable to PostgreSQL write and commit phases rather than unexplained multi-second executor waits.

@MisterVVP MisterVVP changed the title Reduce PostgreSQL insert sequence contention Investigate and eliminate PostgreSQL performance-test tail latency Jul 26, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

In simple words - the problem was not in the SDK itself, but rather in the examples code.

@MisterVVP

Copy link
Copy Markdown
Owner Author

The profile ran five repetitions with 2,000 requests, a one-second warmup, and concurrency 1, 4, and 8. It produced 75 rows, 150,000 successful operations, and zero errors.

For PushNotify_EndToEndManyConfigs at concurrency 4, the median results improved from the #171 baseline:

Metric Baseline Current Change
Throughput 102.82 ops/s 166.52 ops/s +62.0%
p95 160.85 ms 79.05 ms -50.9%
p99 707.69 ms 260.17 ms -63.2%
Max 1.94 s 0.41 s -78.9%

@MisterVVP MisterVVP added the human Human contribution label Jul 26, 2026
@MisterVVP
MisterVVP merged commit 39b16a1 into main Jul 26, 2026
17 checks passed
@MisterVVP
MisterVVP deleted the dev-investigate-postgresql-concurrency-issues branch July 26, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution human Human contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance]: Investigate and reduce PostgreSQL performance-test tail latency

1 participant