Repository navigation
Description
Proposal
Problem
PostgreSQL performance runs show severe and unstable concurrency tail latency.
PR #170 decomposed the push-notification scenarios and confirmed that callback delivery and payload construction are negligible, while PostgreSQL end-to-end push updates develop substantial p95 and p99 latency under concurrency.
Latest validated run:
- CI run: https://github.com/MisterVVP/a2a-cpp/actions/runs/30160528279?pr=170
- Artifact:
perf-artifacts - Operations per row: 2,000
- Errors: 0
PushNotify_EndToEndManyConfigs results:
| Concurrency | p50 | p95 | p99 | max | Throughput |
|---|---|---|---|---|---|
| 1 | ~9.4 ms | ~10.8 ms | ~11.4 ms | ~19 ms | ~104 ops/s |
| 4 | ~9.6 ms | ~161 ms | ~708 ms | ~1.94 s | ~103 ops/s |
Concurrency 4 provides no meaningful throughput improvement while greatly increasing tail latency.
The decomposed rows show approximately:
- callback fan-out p95 at concurrency 4: 0.019 ms;
- payload construction p95: 0.001 ms;
- config lookup p95: 0.77 ms;
- creating eight configs p95: 5.7 ms.
Other PostgreSQL rows have also shown isolated multi-second maxima across adjacent CI runs. The affected scenarios and maxima vary, so a single maximum is not sufficient evidence of an SDK regression.
The current reports do not attribute:
- connection-pool acquisition time;
- transaction begin and commit time;
- individual SQL or logical store-operation time;
- PostgreSQL lock waits;
- CI runner or container scheduling stalls.
The PostgreSQL store uses a fixed-size connection pool and blocks while waiting for an available connection, but pool contention remains a hypothesis rather than a proven root cause.
Goal
Reproduce and explain the PostgreSQL tail stalls, then implement a focused optimization when the root cause is supported by measurements.
Reduce PostgreSQL end-to-end p95 and p99 latency without changing SDK behaviour or hiding outliers through threshold changes.
Scope
- Run at least five controlled repetitions with non-zero warmup.
- Test concurrency 1, 4, and at least one level above the configured connection-pool size.
- Keep fixture setup outside measured operations or report it separately.
- Attribute time to:
- connection-pool acquisition;
- transaction begin and commit;
- task creation and update;
- push-config creation and task-existence checks;
- push-config lookup and list operations;
- individual SQL operations or logical store calls.
- Collect PostgreSQL evidence such as:
pg_stat_statements;- lock and wait observations;
- query counts and timings;
EXPLAIN (ANALYZE, BUFFERS)for relevant queries;- index usage.
- Determine whether the outliers originate from:
- benchmark setup;
- connection-pool contention;
- query or transaction serialization;
- repeated database round trips;
- missing or unused indexes;
- PostgreSQL container or CI-runner stalls;
- another measured source.
- Implement a focused optimization only after the bottleneck is identified.
- Compare before and after results using the same CI-compatible scenarios and request counts.
Requirements
- Do not increase the pool size without evidence.
- Do not relax thresholds to hide outliers.
- Do not perform a broad PostgreSQL store refactor without measured justification.
- Do not treat a single maximum as a regression.
- Keep in-memory behaviour unchanged.
- Preserve TCK and store-conformance behaviour.
- Add regression coverage for any optimization.
Acceptance criteria
- At least five controlled repetitions are collected.
- Warmup and test configuration are documented.
- Setup time is excluded or separately reported.
- Pool-acquisition, transaction, and store-operation timings are available.
- Relevant query plans and index usage are reviewed.
- A reproducible hot path is identified, or the remaining variation is shown to be environmental noise.
- A focused optimization is implemented when the root cause is inside the SDK, or the bottleneck is documented as external.
- PostgreSQL concurrency-4 throughput improves or remains stable.
- PostgreSQL concurrency-4 p95 and p99 improve materially across repeated runs when an SDK optimization is made.
- No regression appears at concurrency 1.
- Push callback, config, and task semantics remain unchanged.
- In-memory and PostgreSQL tests pass.
- Performance reports contain zero unexpected errors.
- Formatting, clang-tidy, sanitizers, CI, and mandatory TCK pass.
Non-goals
- Optimizing callback delivery, which is already negligible.
- Recombining the decomposed performance scenarios.
- Changing public APIs without separate justification.
- Introducing benchmark-only production shortcuts.
Evidence history
- Decomposed push-performance run:
30160528279, artifact8620260453. - Earlier unstable-tail run:
29840589229, artifact8499875367. - Previous adjacent artifact:
8494370641. - Consolidates the newer end-to-end evidence previously tracked in [Performance]: Investigate and reduce PostgreSQL performance-test tail latency #171.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][Performance]: Investigate and reduce PostgreSQL push end-to-end tail latency[/-][+][Performance]: Investigate and reduce PostgreSQL performance-test tail latency[/+]Investigate and eliminate PostgreSQL performance-test tail latency (#172