Skip to content

perf: cut request/response copies and unblock both transports (0.5.0) - #9

Merged
abcsnowwolf merged 1 commit into
mainfrom
perf/a-b-optimizations
Aug 2, 2026
Merged

perf: cut request/response copies and unblock both transports (0.5.0)#9
abcsnowwolf merged 1 commit into
mainfrom
perf/a-b-optimizations

Conversation

@abcsnowwolf

Copy link
Copy Markdown
Contributor
  • keep the parsed request document and view params into it instead of deep-copying params into a second JsonDocument
  • serialize responses directly rather than assembling them in a wrapper document, removing another full-payload deep copy per reply
  • answer tools/list from a body serialized once per tool-set change, invalidated by RegisterTool; the cache is unsynchronized, so document the single-task invariant it relies on
  • add parseRequest(const char*) so neither transport builds a throwaway std::string of the whole request body
  • add RegisterTool(Tool&&) to skip the schema-tree deep copy
  • add MCP_OMIT_TEXT_WHEN_STRUCTURED to drop the duplicated text mirror of a structured result, built and asserted by env:native-omit-text
  • offer a 517-byte preferred ATT MTU (BleServerConfig::preferredMtu); fragment count scales directly with the negotiated MTU, now measured by a transport test rather than asserted in a comment
  • default BleServerConfig::txGapTicks to 0, replacing the unconditional 1-tick inter-fragment delay that cost ~430 ms per 8 KiB message
  • answer a tools/call inline when it completes within MCP_HTTP_FAST_PATH_WAIT_MS instead of waiting for the ~500 ms connection poll that drives the deferred filler
  • raise the RX baseline to 512 and only release growth past 4x baseline, ending the grow/shrink churn around the old 256-byte baseline
  • make the BLE worker stack size configurable (MCP_BLE_WORKER_STACK_SIZE)
  • keep the tool map on plain std::map<std::string, Tool>: std::less<> is C++14 and MCPServer.h compiles as part of the consumer sketch, which the ESP32 Arduino framework still builds as gnu++11
  • match the real NimBLE 2.x setMTU signature (bool, not int) in the mock
  • add scripts/coverage.sh plus env:native-cov and a CI gate at 80% line coverage (currently 89.0%)

* keep the parsed request document and view params into it instead of
  deep-copying params into a second JsonDocument
* serialize responses directly rather than assembling them in a wrapper
  document, removing another full-payload deep copy per reply
* answer tools/list from a body serialized once per tool-set change,
  invalidated by RegisterTool; the cache is unsynchronized, so document
  the single-task invariant it relies on
* add parseRequest(const char*) so neither transport builds a throwaway
  std::string of the whole request body
* add RegisterTool(Tool&&) to skip the schema-tree deep copy
* add MCP_OMIT_TEXT_WHEN_STRUCTURED to drop the duplicated text mirror of
  a structured result, built and asserted by env:native-omit-text
* offer a 517-byte preferred ATT MTU (BleServerConfig::preferredMtu);
  fragment count scales directly with the negotiated MTU, now measured by
  a transport test rather than asserted in a comment
* default BleServerConfig::txGapTicks to 0, replacing the unconditional
  1-tick inter-fragment delay that cost ~430 ms per 8 KiB message
* answer a tools/call inline when it completes within
  MCP_HTTP_FAST_PATH_WAIT_MS instead of waiting for the ~500 ms
  connection poll that drives the deferred filler
* raise the RX baseline to 512 and only release growth past 4x baseline,
  ending the grow/shrink churn around the old 256-byte baseline
* make the BLE worker stack size configurable (MCP_BLE_WORKER_STACK_SIZE)
* keep the tool map on plain std::map<std::string, Tool>: std::less<> is
  C++14 and MCPServer.h compiles as part of the consumer sketch, which the
  ESP32 Arduino framework still builds as gnu++11
* match the real NimBLE 2.x setMTU signature (bool, not int) in the mock
* add scripts/coverage.sh plus env:native-cov and a CI gate at 80% line
  coverage (currently 89.0%)
@abcsnowwolf
abcsnowwolf merged commit 95ea4b8 into main Aug 2, 2026
12 checks passed
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