Repository navigation
Description
Problem
The PostgreSQL connection pool is fixed at four connections:
kDefaultPostgresConnectionPoolSizeis hard-coded to4;PostgresStoreOptionsdoes not expose a pool-size setting;MakePool()always constructs the default-sized pool;Acquire()waits indefinitely when all connections are leased;- task and push-notification stores share the same pool when created through
CreateStoreBundle().
After the executor-wide serialization work in #172, the fixed pool is now a visible concurrency bottleneck rather than an implementation detail.
Evidence
Main-branch performance run: https://github.com/MisterVVP/a2a-cpp/actions/runs/30399637991
Commit: ab839d4b094dcb2f9f7154c0cd85499d8e356216
Median postgres-tail results:
| Scenario | Concurrency | Throughput | p95 | Connection-acquire wait p95 |
|---|---|---|---|---|
PushConfig_CreateMany |
4 | 601.71 ops/s | 7.39 ms | 0.003 ms |
PushConfig_CreateMany |
8 | 575.83 ops/s | 22.58 ms | 15.12 ms |
PushConfig_ListManyConfigs |
4 | 4092.39 ops/s | 1.25 ms | 0.0002 ms |
PushConfig_ListManyConfigs |
8 | 3877.16 ops/s | 5.40 ms | 4.35 ms |
PushNotify_EndToEndManyConfigs |
4 | 299.19 ops/s | 14.70 ms | 0.004 ms |
PushNotify_EndToEndManyConfigs |
8 | 292.69 ops/s | 37.46 ms | 22.47 ms |
SendMessage_CreateTask |
4 | 1264.24 ops/s | 3.82 ms | 0.0005 ms |
SendMessage_CreateTask |
8 | 1251.26 ops/s | 11.22 ms | 6.85 ms |
SendMessage_FollowUpExistingTask |
4 | 1125.58 ops/s | 4.18 ms | 0.0006 ms |
SendMessage_FollowUpExistingTask |
8 | 1114.48 ops/s | 12.58 ms | 7.72 ms |
At concurrency 8, throughput stops improving while connection-acquire wait becomes most of the additional tail latency. This aligns directly with the current four-connection limit.
Goal
Allow SDK users to configure PostgreSQL pool capacity and verify, using the existing diagnostics, that an appropriately sized pool removes artificial acquisition contention.
Scope
- Add a PostgreSQL pool-size field to
PostgresStoreOptions. - Preserve the current size of
4as the backward-compatible default. - Validate that the configured size is greater than zero and return a clear validation error otherwise.
- Pass the configured size through
MakePool()and all PostgreSQL factory/store construction paths. - Ensure task and push-notification stores created as one bundle share the configured pool.
- Expose the pool size to the TCK/performance SUT configuration so CI can compare pool sizes without code changes.
- Record the configured pool size in machine-readable and Markdown performance output.
- Add deterministic tests for default, custom, invalid, and shared-bundle configuration.
- Run a controlled PostgreSQL comparison with pool sizes
4,16, and64at concurrency4,16, and64. - Document the option and explain that it should be sized against expected concurrent database operations and PostgreSQL connection limits.
Out of scope
- Dynamic pool resizing.
- Replacing libpq or introducing asynchronous PostgreSQL I/O.
- Query or schema optimization.
- Changing the default pool size without controlled evidence.
- Adding acquisition timeout or cancellation semantics; those can be tracked separately if needed.
Acceptance criteria
-
PostgresStoreOptionsexposes a pool-size setting with default4. - A pool size of
0is rejected before connections are opened. - All PostgreSQL factory paths use the configured size.
- A task/push store bundle shares one pool with the configured capacity.
- TCK/performance runners can select the pool size through configuration or environment variables.
- Performance reports include pool size as scenario metadata.
- In a same-run comparison, pool size
16at concurrency16and pool size64at concurrency64reduce connection-acquire-wait p95 by at least 80% versus pool size4. - The comparison reports throughput, p95, p99, max latency, and connection-acquire wait, with zero operation errors.
- Concurrency-4 results are checked for material regressions.
- Unit, integration, performance smoke, TCK, and repository validation pass.
Tracking
This is step 3 of the performance-improvement sequence tracked by #146, after completed #167 and #84.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][Perf]: Make PostgreSQL connection pool size configurable[/-][+][Performance]: Make PostgreSQL connection pool size configurable[/+]MisterVVP commentedon Jul 29, 2026
Async pSQL I/O is worth a separate issue