Skip to content

refactor: simplify SDK JSON parsing with simdjson - #314

Merged
MisterVVP merged 4 commits into
mainfrom
refactor/311-simdjson-parsing
Oct 24, 2026
Merged

MisterVVP merged 4 commits into
mainfrom
refactor/311-simdjson-parsing

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #311. Client and server JSON parsing now shares a private simdjson implementation. It validates complete input, owns padded buffers and parser lifetimes, reuses parsers per thread without a global lock, and preserves original numeric tokens for typed decoding.

  • Remove both custom JSON scanners, the JSON-RPC flat-message decoder, incoming JSON-RPC params and client-result Struct/Value round trips, and the ListTasks/SSE result-replacement paths. Delete the scanner-only tests, benchmarks and thresholds. The SDK sources/headers contain about 540 fewer lines; there are two fewer CTest checks overall.
  • Replace duplicate repeated/message fields with their last occurrence, including empty values and aliases; reject duplicate known fields in protobuf fallbacks. Cache parsers only up to 1 MiB of input capacity and release larger parsers after use.
  • Preserve protobuf decoding for exact numeric/base64/well-known-type semantics and version-dependent null behavior. Keep signed-card verification on the original JSON and retain the RFC 8785 serializer. No public interface exposes simdjson types.
  • Make simdjson a core dependency with signing disabled, update static package exports, manifests, installers, tutorial images and macOS CI, and document the inventory and compatibility policy in book/src/compatibility/json-parsing.md. Automatic Linux dependency installation requires Ubuntu 24.04+ or Debian 12+; the installation guide provides a manual simdjson prefix for older releases.
  • Replace scanner implementation tests with compact compatibility/security/threading coverage and extend existing cross-binding scenarios with binary parts and null/list metadata.

Release compatibility: development toward v0.6.0 removes a2a/core/json_value.h and limits general JSON input to 64 MiB / nesting depth 128. The released v0.5.2 behavior is unchanged.

Measurements

Same Linux host, GCC 15.3, protobuf 3.21.12, simdjson 3.12.3, Release builds with signing disabled. Candidate 64ea023 and baseline bed242d used identical benchmark definitions. Median CPU microseconds, three repetitions, 0.1-second minimum per repetition on a shared host:

Workload Before After
Small SendMessage request 12.78 1.43
Agent Card 21.14 2.00
SSE StreamResponse payload 21.20 3.84
Large history/artifact payload, 290,486 bytes 2,035.36 339.05
HTTP+JSON client ListTasks, 200 tasks 638.64 629.12
JSON-RPC client ListTasks, 200 tasks 876.59 621.81
JSON-RPC server GetTask, in-process binding/dispatch 110.22 42.79

Warmed C++ new/new[] calls per parse fell from 305 to 10 for small messages, 487 to 25 for cards, 479 to 60 for SSE payloads, and 5,161 to 1,668 for the large payload. These counts exclude direct malloc calls and retained parser buffers. Peak process RSS remained approximately 13 MiB. In-process timings and parser-only results do not establish network latency/throughput improvements; large HTTP+JSON ListTasks processing was nearly unchanged.

Authorship and AI usage

  • Contains substantive content written by a human
  • Contains substantive content generated by an AI agent

Implementation, tests, build/dependency updates and documentation were generated by an AI agent.

Testing

  • ./scripts/verify_changes.sh exited 0 before committing e727535, with Ubuntu simdjson 3.6.4, GCC 14.2 and Clang 18.1.8: formatting, Debug/signing-enabled/PostgreSQL build, 804 CTest checks with two expected in-process TLS skips, and all 135 clang-tidy file checks.

  • Changed parser sources compile against simdjson 3.0.1.

  • Tutorials CI passes at e727535, including host and Docker tutorial builds. Local tutorial validation also passed with simdjson 3.6.4 during the initial migration. Tutorial images install simdjson development, static and runtime packages; Alpine's CMake export requires the separately packaged static archive.

  • Both signing-enabled Debug and signing-disabled Release configurations build. Installed signing-disabled package consumer builds and runs.

  • Exact-value compatibility probe for a dynamic protobuf map<string,int64> passed, including the int64 maximum and an unquoted integer beyond binary64's exact range.

  • Eight ProtoJSON parsing benchmarks pass the scoped Go threshold check, including all five newly covered cases; three repetitions with a 0.1-second minimum. The new limits have roughly 6–13× headroom over measured medians on this host.

  • Installer dry-run tests accept Ubuntu 24.04 / Debian 12 and reject Ubuntu 22.04 / Debian 11 / unsupported Linux distributions before package installation.

  • Performance smoke: 54 rows, zero errors, gRPC and HTTP+JSON with the in-memory backend, including wire scenarios.

  • mdbook build book succeeds; git diff --check succeeds.

  • Unmodified upstream TCK d4d6fae7887f88ef607fb461c13e3b0e1802f19b: gRPC, JSON-RPC and HTTP+JSON with both stores. Each store: 249 passed, 16 conditional skips, zero failed assertions.

  • All seven PR workflows passed at e727535: main CI, TCK, CodeQL, Tutorials, Docs, Go benchmark runner, and commit messages. Main CI passed all 14 jobs, including Windows, macOS, benchmarks, sanitizers, interoperability, and performance checks.

Known validation gaps: upstream reports 80.9% mandatory / 80.0% overall because 25 registered requirements have no executable fixtures. No requirements, test fixtures, filters or reports were weakened. The maintainer explicitly authorized committing with at least 80% TCK compliance. OSV Scanner 2.7.0 was run, but its api.osv.dev query was blocked by the environment proxy (CONNECT 403); this is not a successful vulnerability scan.

Checklist

  • ./scripts/verify_changes.sh passed locally
  • Docs updated for behavior and dependency changes

Closes #311. Replace custom scanners and incoming Struct/Value bridges
with shared private parsing, preserving protobuf JSON compatibility.

Generated with AI assistance.
@MisterVVP MisterVVP added the AI agent AI agent contribution label Oct 22, 2026 — with ChatGPT Codex Connector
@MisterVVP
MisterVVP marked this pull request as draft October 22, 2026 20:32
@MisterVVP MisterVVP self-assigned this Oct 22, 2026
@MisterVVP MisterVVP added refactoring Constant technical improvements which are not necessarily related to any issue. performance Performance improvement related tasks based on benchmark results. Performance tests changes. labels Oct 22, 2026
Comment thread benchmarks/bench_protojson.cpp Resolved
Comment thread benchmarks/thresholds.json Resolved
Use field-result accessors supported across simdjson 3.x.
Install development and runtime packages in both tutorial images.
Alpine's development package exports a static CMake target whose
archive is provided separately by simdjson-static.
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T16:24:15.955804Z e727535 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: f07b8bafc8

ℹ️ 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".

Comment thread src/core/protojson.cpp Resolved
Comment thread scripts/install_build_deps.sh Resolved
Comment thread src/core/json.cpp Resolved
Replace duplicate repeated/message fields instead of merging them and reject duplicates in protobuf fallbacks. Bound cached parser capacity to 1 MiB, add wide parsing benchmark thresholds, and require compatible Linux releases for automatic dependency installation.

Extend existing C++ coverage and document the manual dependency installation path.
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this again pls

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: e727535d02

ℹ️ 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 marked this pull request as ready for review October 24, 2026 19:39
@MisterVVP

Copy link
Copy Markdown
Owner Author

LGTM

@MisterVVP
MisterVVP merged commit 1ac17b5 into main Oct 24, 2026
23 checks passed
@MisterVVP
MisterVVP deleted the refactor/311-simdjson-parsing branch October 24, 2026 19:44
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. refactoring Constant technical improvements which are not necessarily related to any issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate client and server SDK JSON parsing to simdjson

1 participant