Skip to content

perf(bench): evaluate CBOR for remote-access IR#195

Open
thaodt wants to merge 1 commit into
aimdb-dev:mainfrom
thaodt:156-bench
Open

perf(bench): evaluate CBOR for remote-access IR#195
thaodt wants to merge 1 commit into
aimdb-dev:mainfrom
thaodt:156-bench

Conversation

@thaodt

@thaodt thaodt commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Description

Investigates whether CBOR should replace JSON as the self-describing representation at AimDB's type-erased remote-access boundary.

This PR:

  • adds deterministic numeric, nested and byte-heavy record fixtures
  • compares the current JSON-tree path, direct JSON, CBOR-to-JSON transcoding, native CBOR trees and direct CBOR
  • adds allocation, latency, throughput and request/write/subscription-event envelope benchmarks
  • adds an isolated no_std Cortex-M fixture for comparing linked JSON and CBOR footprint
  • documents the evidence and final decision in Design 046.

Result

  • Direct JSON was 2.06x–2.49x faster to encode and 2.41x–3.54x faster to decode than the JSON-tree path.
  • Native CBOR reduced ordinary structured payloads by about 26%, but did not outperform direct JSON CPU time.
  • For the byte-heavy fixture, native CBOR reduced frame size by about 70% and was more than 12x faster in the in-memory envelope prototype.
  • The comparable Cortex-M CBOR image required 9592 additional flash-like bytes (+38.5%) versus JSON.
  • CBOR-to-JSON transcoding was consistently worse than serializing JSON directly.

The resulting decision is an evidence-backed no-go for replacing the current JSON representation or changing AimX v2 as part of this issue.

The recommended follow-up is a compatibility-preserving direct-JSON-bytes optimization. A native binary remote edge should only be considered separately when there is a concrete byte-heavy consumer, protocol negotiation, bounded decoding and a target memory budget.

CBOR remains isolated to the unpublished benchmark crate and standalone footprint fixture. This PR does not change any production API, connector behavior or wire protocol.

Related Issue

Checklist

  • I have read the CONTRIBUTING.md document.
  • My code follows the project's coding standards.
  • I have added tests to cover my changes.
  • All new and existing tests passed (make check).
  • I have updated the documentation accordingly.

@thaodt
thaodt requested a review from lxsaah as a code owner July 19, 2026 05:09
@thaodt

thaodt commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator Author

@lxsaah open this PR for your review, its for evaluation, not intended for merge. Please check the PR's description for detail and run benches yourself to validate my result too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant