Add an ArduinoJSON arena defaulting to internal memory#52
Merged
Conversation
…s heap allocation churn while also saving a few CPU cycles by avoiding PSRAM for these routine messages.
There was a problem hiding this comment.
Pull request overview
This PR introduces a reusable ArduinoJson allocator backed by a fixed internal-RAM bump arena (with PSRAM/heap fallback) and wires it into SendspinClient::process_json_message() to reduce allocation churn and PSRAM traffic on the network thread.
Changes:
- Added
SendspinArenaAllocator(bounded bump allocator with fallback) andmake_json_document(arena)helper. - Added
SendspinClientConfig::json_arena_size(default 2048 bytes) and aSendspinClient-owned arena reused across incoming JSON messages. - Documented the new arena behavior in internal and integration docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/platform/json_arena.h |
New internal-RAM bump arena ArduinoJson allocator with PSRAM-preferring fallback. |
src/client.cpp |
Creates optional arena from config and reuses it for parsing incoming JSON messages. |
include/sendspin/config.h |
Adds json_arena_size config knob with default and documentation. |
include/sendspin/client.h |
Adds forward declaration and member for the arena allocator. |
docs/internals.md |
Documents incoming JSON parse arena and updates references to client.cpp. |
docs/integration-guide.md |
Adds json_arena_size to the configuration table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This avoids heap allocation churn while also saving a few CPU cycles by avoiding PSRAM/reducing cache pressure for these routine messages.
Defaults to a 2048 byte arena in internal memory. ArduinoJSON uses 1024 of those bytes for small messages, and the rest is a copy of the original message.