Skip to content

perf(server): streamline async dispatch and HTTP writes - #340

Merged
MisterVVP merged 5 commits into
perf/async-client-server-optimizationsfrom
perf/async-server-hot-path
Nov 22, 2026
Merged

MisterVVP merged 5 commits into
perf/async-client-server-optimizationsfrom
perf/async-server-hot-path

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Keep SSE write buffers on the connection and move the acknowledgment through the write queue. A write ID prevents late cancellation from closing a connection after that write has completed.
  • Count active native unary replies through serialization. Uncontended compact replies, including short task status messages and lists of up to four small tasks, encode on the dispatcher. Contended replies and expensive shapes use the HTTP application executor.
  • Store the typed stop callback in each dispatcher call and skip deadline clock reads where no deadline exists. This applies to both HTTP and gRPC.
  • Run the normal and PostgreSQL write CI matrices at 1, 16, 64, and 256 concurrency. The PostgreSQL tail job uses 16, 64, and 256 alongside its focused concurrency-1 profile.

Tradeoffs and evidence

  • Each SSE event waits for socket acceptance. I ruled out batching events and removing the per-request strand to preserve per-write backpressure and serialized cancellation and interceptor callbacks.
  • The existing wire benchmark, profiled over 4,096 requests per workload, recorded 6.3 fewer server malloc calls per two-event SSE request and 4.1 fewer per GetTask. The uninstrumented concurrent GetTask run used about 5% less median server CPU per request. SSE throughput varied across repeats.

Follow-up benchmark

HTTP+JSON GetTask medians in requests per second, using two repeats on the same pinned server and client cores.

Concurrency Sync Previous async Updated async
1 9,919 7,252 7,827
16 18,195 17,490 17,725
64 20,361 20,475 22,109
256 16,344 18,713 20,306

At concurrency 1, the updated async server measured 2,152 requests/s for ListTasks with a 20-task fixture and 3,673 requests/s for finite SSE. Sync measured 2,314 and 4,917 requests/s, respectively.

Testing

  • ./scripts/verify_changes.sh with Asio and PostgreSQL enabled.
  • Mandatory TCK on gRPC, JSON-RPC, and HTTP+JSON with in-memory and PostgreSQL stores. Each store had 216 passes, 13 skips, and zero failures. All 88 previously passing mandatory requirements retained their passing transport results.
  • Performance smoke with 54 cases and zero errors. Another 18 targeted concurrency-256 cases passed across the in-memory and PostgreSQL stores.
  • mdbook build book.
  • The separate optional signing profile failed AgentCardSigningJsonTest.IndependentRfc8785Corpus on two existing rejection vectors.

Authorship

  • Contains substantive content generated by an AI agent.

@MisterVVP MisterVVP added the AI agent AI agent contribution label Nov 21, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Nov 22, 2026
@MisterVVP MisterVVP added the performance Performance improvement related tasks based on benchmark results. Performance tests changes. label Nov 22, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T20:16:06.176474Z f213289 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd70eb046e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: f213289bbd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP
MisterVVP merged commit 82d34de into perf/async-client-server-optimizations Nov 22, 2026
23 checks passed
@MisterVVP
MisterVVP deleted the perf/async-server-hot-path branch November 22, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution performance Performance improvement related tasks based on benchmark results. Performance tests changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant