Repository navigation
Remove three more admission-path allocation sites and re-derive the ESP stacks - #229
Merged
Merged
Conversation
7 tasks done
kahrendt
force-pushed
the
alloc-5-admission-tail
branch
from
November 3, 2026 14:38
401cf8f to
1e5a165
Compare
ConnectionManager keeps the last-played server_id, and the persist request carries it, as an IdText rather than a heap string; admission takes it as a view, empty meaning none. RecordStore::persist_records() returns before reserving when no record write is owed, which is every flush a playback handoff stages for the last-played server alone. Accept to admission: 11 -> 8 allocations under libc++, 13 -> 10 under libstdc++.
push_pairing_note() appends through InboxSlot::update() instead of merging a one-element vector, so a pairing or trust note no longer allocates a delta. Accept to admission: 8 -> 7 allocations under libc++, 10 -> 9 under libstdc++.
ClientPlayerStateObject::supported_commands becomes an EnumSet, a one-byte bit set that ActivitySet now shares, so building, copying and filtering a client/state no longer allocates. client/state lists the commands in enumerator order, the order the player added them in. Accept to admission: 7 -> 6 allocations under libc++, 9 -> 8 under libstdc++; one client/state publish: 3 -> 0.
Re-run tools/stack_usage over the branch at -Os and -Og. The protocol task's reachable chain is 5,920 / 6,400 bytes, so its 7,168 default stands; the websocket client's -Og total moves to 3,968, inside its 4,608 default. No default changes.
ClientPlayerStateObject is trivially copyable now that its supported commands are a set, so std::move() into the message did nothing (performance-move-const-arg).
kahrendt
force-pushed
the
alloc-5-admission-tail
branch
from
November 3, 2026 15:15
1e5a165 to
fbee9a9
Compare
kahrendt
marked this pull request as ready for review
November 3, 2026 15:26
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the allocation-reduction changes and related ESP stack measurement updates.
No open issues 🎉
What changed in this PR
This PR continues the library’s allocation-reduction work by removing three admission-path allocation sites and refreshing ESP stack measurements without changing stack defaults.
Changes:
- Uses fixed-capacity storage for last-played server IDs and player commands, appends pairing notes directly, and skips unnecessary persistence allocation.
- Updates allocation expectations to 6/8 for admission and zero for player
client/state, with coverage for sparse command sets and enumerator ordering. - Updates measured ESP stack usage, which remains within existing defaults.
| File | Description |
|---|---|
| tools/stack_usage/README.md | Refreshes ESP stack measurements and sizing calculations. |
| tests/test_protocol.cpp | Checks sparse, out-of-order command-set serialization. |
| tests/test_player_role.cpp | Uses command sets in expected player state. |
| tests/test_allocations.cpp | Lowers admission and state-publication allocation expectations. |
| tests/test_admission.cpp | Adapts last-playback cases to empty-string semantics. |
| src/record_store.cpp | Skips allocation when no record writes are pending. |
| src/protocol.cpp | Serializes supported commands in enumerator order. |
| src/protocol_messages.h | Introduces a shared one-byte enum set for activities and commands. |
| src/player_role.cpp | Builds supported commands without vector allocation. |
| src/connection_manager.h | Stores the last-played ID inline and exposes a view. |
| src/connection_manager.cpp | Uses the stored ID view for admission decisions. |
| src/client.cpp | Removes temporary pairing-note and last-played-ID allocations. |
| src/admission.h | Accepts the last-playback ID as a string view. |
| include/sendspin/client.h | Updates private persistence helpers to accept string views. |
Review effort: Balanced
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.
Layer 5 of 7 (base:
alloc-4-handshake-state). Accept to admission: 11 -> 6 allocations under libc++, 13 -> 8 under libstdc++; oneclient/statepublish: 3 -> 0.Summary
Three more admission-path allocation sites go: the last-played server id, the pairing notes and the player's
client/stateobject. This layer also re-derives the ESP task stacks for layers 2 to 5.Changes
IdTextin the manager and in the persist request, and admission takes it as a view, empty meaning none.note_last_played_server()andwrite_last_played_server()take astring_view; they are private members, andclient.hgains<string_view>.RecordStore::take_dirty_writes_locked()returns before reserving when no record write is owed, which is every flush a playback handoff stages for the last-played server alone.push_pairing_note()appends throughInboxSlot::update()instead of merging a one-element vector.ClientPlayerStateObject::supported_commandsis anEnumSet, a one-byte bit set thatActivitySetnow shares.client/statelists the commands in enumerator order, which is the order the player added them in, so the wire output is unchanged.tools/stack_usage/README.md: the protocol task's reachable chain is 5,920 / 6,400 B (-Os / -Og), so its 7,168 default stands; the websocket client's -Og total moves to 3,968, inside its 4,608 default. No default changes.Testing
Still allocating, on purpose: copies of the public
ServerInformationObject, and the pairing-note slot's vector on its first note after each drain.