perf: cut request/response copies and unblock both transports (0.5.0) - #9
Merged
Conversation
abcsnowwolf
commented
Aug 2, 2026
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%)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.