You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(memory): NOTE_NO_RESPONSE_RAII opt-out for arena-only builds
Phase 1 Response RAII calls `Allocator::deallocate` on every interned string in `~Response()`. For users whose Allocator's `free` is a no-op — arena_allocator, heap_reset_allocator, custom pool — this is pure overhead: ~248 B AVR flash for dtor symbols + the `release_string_fields` helper, plus per-Response RAM for the AllocatorRef. The strings are already reclaimed wholesale by `arena.reset()` / `pool.reset()`.
Define `NOTE_NO_RESPONSE_RAII=1` to drop the cleanup entirely. Under the flag, codegen omits:
* `Response::alloc_` member and `note::AllocatorRef`.
* `~Response()` body + the custom move ctor / move-assignment.
* The SINGLETON-path `rsp_.alloc_.reset(...)` line in each generated
`execute()`.
* The non-SINGLETON `Notecard::execute(req, temp_alloc)` per-call
overload (its contract depends on per-Response allocator tracking).
Not auto-implied by NOTE_MINIMAL: a NOTE_MINIMAL user can still plug in the default heap `Allocator{}` (AVR-libc has malloc/free), where the flag would silently leak interned response strings.
Tests on the `with-RAII` contract in `test_allocator_lifetime.cpp` are gated `#if !NOTE_NO_RESPONSE_RAII` — they pin behaviour the flag intentionally removes. Same gate added to the per-call overload tests in test_notecard.cpp / test_notecard_streaming.cpp.
AVR `avr-notecpp` size delta: default (RAII on): 27,404 B flash, 782 B RAM NOTE_NO_RESPONSE_RAII=1: 25,198 B flash, 773 B RAM → -2,206 B flash, -9 B RAM
The NO_RAII number matches the pre-Phase-1 avr_baselines.json entry exactly, confirming the full Phase 1 cost is recoverable on AVR.
Host test counts: default: 1896 / 1896 pass NOTE_NO_RESPONSE_RAII=1: 1889 / 1889 pass (7 RAII tests gated) NOTE_SINGLETON=1: 1892 / 1893 (1 pre-existing failure) SINGLETON + NO_RAII: 1888 / 1889 (same pre-existing failure)
0 commit comments