Skip to content

Benchmark MCP protocol helpers - #3031

Open
HarshPopat23 wants to merge 2 commits into
sourcemeta:mainfrom
HarshPopat23:bench/mcp-performance-baselines-20261025
Open

HarshPopat23 wants to merge 2 commits into
sourcemeta:mainfrom
HarshPopat23:bench/mcp-performance-baselines-20261025

Conversation

@HarshPopat23

Copy link
Copy Markdown
Contributor

Summary

The benchmark harness currently has no dedicated MCP cases. This PR establishes reproducible baselines for metadata validation, header mirroring, result serialization and subscription intersection, so future optimizations can be evaluated against consistent workloads.

Adds 22 deterministic microbenchmarks, registered and linked only when SOURCEMETA_CORE_MCP is enabled. No production APIs or validation behavior change.

Benchmark coverage

Area | Workloads -- | -- JSON parsing | Parse cached metadata envelopes with 0 and 128 additional metadata keys, separately from MCP validation Metadata validation | Validate already parsed requests, including valid inputs and invalid progress tokens Header mirroring | Generate and validate headers with 2 and 64 descriptors, including Unicode sentinel encoding, unrelated headers and late mismatches Result serialization | Serialize 1 and 256 resources through const-input and move-taking writers; measure invalid-result rejection separately Subscription intersection | Intersect overlapping and disjoint lists containing 8 and 512 URIs per side

Measurement boundaries

  • Fixture construction and preflight correctness checks occur outside timed loops.

  • Preflight checks remain active in Release builds.

  • Results use the existing benchmark optimization barrier.

  • Per-iteration output allocation and destruction are included.

  • The move-writer benchmark explicitly includes the fresh-payload copy required for each repetition. It is labelled copy + move-write, rather than implying a copy-free comparison.

  • Parsing, successful validation, rejection and serialization have distinct benchmark names.

benchmark/MCP.markdown documents fixture sizes, timing boundaries, execution commands and the compiler, build, allocator and machine information needed for reproducible comparisons.

Files changed

  • benchmark/CMakeLists.txt -conditional MCP benchmark registration and linkage.

  • benchmark/mcp.cc - workloads and Release-active correctness controls.

  • benchmark/MCP.markdown - measurement and reproduction instructions.

Verification

  • Release build passed with GCC 13.3 and the system allocator.

  • All 22 filtered MCP benchmarks completed successfully.

  • JSON output verified for unique registrations, finite positive timings and three repetitions.

  • Existing MCP unit suite: 1,420 passed, zero failed.

  • MCP-disabled configuration verified to exclude benchmark/mcp.cc.

  • Repository clang-format checks and git diff --check passed.

Limitations

These are authored microbenchmark fixtures, not captured production traffic. They measure local helper operations, not model generation, network latency or a complete MCP transport runtime.

This PR establishes baselines; it makes no speedup claim and introduces no CI timing thresholds. Allocation profiling, the full repository test matrix and Windows/macOS builds were not run locally.

Add gated MCP benchmarks for parsed metadata, separate JSON parsing, header
mirroring, result writers and subscription intersection. Include Release-active
fixture controls and reproducible measurement instructions.

Signed-off-by: HarshPopat23 <musichk61@gmail.com>

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 3 files

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="benchmark/MCP.markdown">

<violation number="1" location="benchmark/MCP.markdown:18">
P3: The executable path is wrong on Windows: CMake places it under `build/bin`, not `build/benchmark`. Document the platform-specific path alongside the multi-configuration path.</violation>

<violation number="2" location="benchmark/MCP.markdown:25">
P3: The mimalloc comparison only applies on Linux/macOS builds without sanitizers. Add that qualifier here so readers do not run an OFF build expecting mimalloc on Windows or sanitizer builds.</violation>
</file>

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Re-trigger cubic

Comment thread benchmark/MCP.markdown
`cmake -LA -N build` output, compiler/version (`c++ --version` or the platform
compiler equivalent), CPU/OS, build configuration, SIMD flags, and system load.
The command above explicitly selects the system allocator. Repeat in a separate
build with `SOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR=OFF` to study the configured

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The mimalloc comparison only applies on Linux/macOS builds without sanitizers. Add that qualifier here so readers do not run an OFF build expecting mimalloc on Windows or sanitizer builds.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At benchmark/MCP.markdown, line 25:

<comment>The mimalloc comparison only applies on Linux/macOS builds without sanitizers. Add that qualifier here so readers do not run an OFF build expecting mimalloc on Windows or sanitizer builds.</comment>

<file context>
@@ -0,0 +1,76 @@
+`cmake -LA -N build` output, compiler/version (`c++ --version` or the platform
+compiler equivalent), CPU/OS, build configuration, SIMD flags, and system load.
+The command above explicitly selects the system allocator. Repeat in a separate
+build with `SOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR=OFF` to study the configured
+mimalloc allocator; do not mix allocator/build/compiler results. The harness
+JSON records timings and core count, not all of this environment information.
</file context>
Suggested change
build with `SOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR=OFF` to study the configured
build with `SOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR=OFF` to study the configured
(Linux/macOS, non-sanitizer builds only; elsewhere OFF uses the system allocator too)

Comment thread benchmark/MCP.markdown
-DSOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR=ON
cmake --build build --config Release --target sourcemeta_core_benchmarks
# Single-configuration generators; multi-configuration builds may add Release/
./build/benchmark/sourcemeta_core_benchmarks --filter MCP_ --output build/mcp.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The executable path is wrong on Windows: CMake places it under build/bin, not build/benchmark. Document the platform-specific path alongside the multi-configuration path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At benchmark/MCP.markdown, line 18:

<comment>The executable path is wrong on Windows: CMake places it under `build/bin`, not `build/benchmark`. Document the platform-specific path alongside the multi-configuration path.</comment>

<file context>
@@ -0,0 +1,76 @@
+  -DSOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR=ON
+cmake --build build --config Release --target sourcemeta_core_benchmarks
+# Single-configuration generators; multi-configuration builds may add Release/
+./build/benchmark/sourcemeta_core_benchmarks --filter MCP_ --output build/mcp.json
+```
+
</file context>

@augmentcode

augmentcode Bot commented Oct 25, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Establishes reproducible performance baselines for MCP protocol helpers.

  • Adds 22 deterministic microbenchmarks using the existing harness.
  • Separates JSON parsing from metadata validation and invalid-token rejection.
  • Measures header generation, validation, and late mismatch rejection.
  • Covers const-input serialization, explicit copy + move-writing, and invalid-result rejection.
  • Exercises overlapping and disjoint subscription intersections at two sizes.
  • Keeps fixture setup and Release-active checks outside timing, while including output allocation and destruction.
  • Registers and links the new cases only when MCP is enabled.
  • Documents fixture sizes, measurement boundaries, execution commands, and environment recording.
Scope: No production API or validation changes, speedup claims, or CI timing thresholds.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode 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.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Use a designated parameter descriptor initializer and make arithmetic
precedence explicit for the macOS LLVM warnings-as-errors build.

Signed-off-by: HarshPopat23 <musichk61@gmail.com>
HarshPopat23 added a commit to HarshPopat23/core that referenced this pull request Oct 25, 2026
Use descriptive comparator parameter names for readability-identifier-length.
Carry the existing sourcemeta#3031 benchmark lint fixes onto this dependent branch:
designated descriptor initialization and explicit arithmetic grouping.
No validation or benchmark behavior changes.

Signed-off-by: HarshPopat23 <musichk61@gmail.com>

This branch has not been deployed

No deployments
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