Skip to content

Store ConnectionManager's bounded connection lists inline - #136

Merged
kahrendt merged 3 commits into
mainfrom
inline-connection-containers
Sep 29, 2026
Merged

kahrendt merged 3 commits into
mainfrom
inline-connection-containers

Conversation

@kahrendt

@kahrendt kahrendt commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

The nursery, the hello retries, disconnect()'s collect list and loop()'s nursery copy all have compile-time bounds, so their storage can live in the ConnectionManager object instead of a heap buffer. Adds InlineVector, an std::array-plus-count container that resets vacated slots on erase and clear, so a removed connection is released at the removal rather than lingering in its slot. Names the bounds MAX_NURSERY_ENTRIES and MAX_MANAGED_CONNECTIONS.

deferred_releases_ and the pending event queues stay std::vector as they have no compile-time bound, since network-thread rejections scale with the runtime server_max_connections.

The nursery, the hello retries, disconnect()'s collect list and loop()'s
nursery copy all have compile-time bounds, so their storage can live in
the ConnectionManager object instead of a heap buffer. Add InlineVector,
a std::array-plus-count container that resets vacated slots on erase and
clear, so a removed connection is released at the removal rather than
lingering in its slot. Name the bounds MAX_NURSERY_ENTRIES and
MAX_MANAGED_CONNECTIONS.

deferred_releases_ and the pending event queues stay std::vector: they
have no compile-time bound, since network-thread rejections scale with
the runtime server_max_connections.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The unconditional noexcept contract and unmeasured embedded teardown stack increase should be addressed.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Moves compile-time-bounded connection storage inline to reduce heap allocation and fragmentation.

Changes:

  • Adds and tests InlineVector.
  • Applies fixed-capacity storage to bounded connection lists.
  • Introduces named connection-capacity constants.
File Description
src/​inline_vector.h Adds the inline fixed-capacity container.
src/​connection_manager.h Defines bounds and replaces bounded vectors.
src/​connection_manager.cpp Uses inline storage in lifecycle paths.
tests/​test_inline_vector.cpp Tests erase, release, clear, and swap behavior.
tests/​CMakeLists.txt Registers the new tests.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/connection_manager.cpp Resolved
Comment thread src/inline_vector.h Resolved
Comment thread src/inline_vector.h Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The bounded capacities are correctly derived and the new container behavior is adequately tested.

Review effort: Balanced
Findings: None

Resolved since last review (3)

@kahrendt
kahrendt merged commit 3748e96 into main Sep 29, 2026
8 checks passed
@kahrendt
kahrendt deleted the inline-connection-containers branch September 29, 2026 14:17
kahrendt added a commit that referenced this pull request Sep 29, 2026
…on-support

Brings in #126 (SENDSPIN_ENABLE_OPUS and the flac-or-pcm format rule)
and #136 (InlineVector for ConnectionManager's bounded lists).

Format validation: RC1 already refused a list without flac or pcm, and
also refuses an empty list because the player role is always advertised
and roles/player/v1.md requires a non-empty supported_formats. That
rule stands; main's "empty leaves the player out of the hello" is
dropped. The two validators are folded into audio_formats_valid(), which
adds main's refusal of an opus entry in a build without the decoder. The
format tests become one table in test_player_role.cpp, main's opus
stream refusal test is ported to the encrypted lifecycle fixtures, and
test_decoder.cpp's Opus cases are guarded so the no-opus CI job builds.

InlineVector: RC1's MAX_OPEN_CONNECTIONS stays (now derived from the new
MAX_NURSERY_ENTRIES) in place of main's MAX_MANAGED_CONNECTIONS. Beyond
main's sites, promote_or_arbitrate_nursery_entry() takes a NurseryEntry*
and the record-revocation collect list is inline too.
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.

2 participants