app-server: forwarded core events rebuild the subscriber list
What variant of Codex are you using?
App Server
What feature would you like to see?
I found a potential performance concern in current app-server source rather than a confirmed user-visible bug. Please consider retaining an immutable subscriber snapshot for a listener and replacing it only when thread membership changes, if that can preserve the current subscription and teardown semantics.
Additional information
Evidence
- Source-proven:
thread_lifecycle.rs:309-340callssubscribed_connection_ids(conversation_id).awaitfor every forwarded core event before constructing the thread-scoped sender. - Source-proven:
thread_state.rs:308-323stores all thread entries behind oneArc<Mutex<ThreadStateManagerInner>>;subscribed_connection_idsacquires that mutex and collects the thread'sHashSetinto a freshVec. - Source-proven: membership is mutated by explicit subscribe, unsubscribe, add, and connection-removal paths in
thread_state.rs:472-589, whereas the lookup above runs per forwarded event. - Historical context only: closed, unmerged PR #29545 proposed a watcher-backed immutable connection-ID snapshot, including an empty snapshot at teardown. Its bundled benchmark claims are not measurement for this report, and the audited current source still rebuilds the vector.
Impact
Not measured. Global-lock contention, allocation volume, and listener latency have not been measured. Each forwarded event awaits a mutex shared by the manager's thread map and allocates a vector containing all current subscriber IDs; the work may therefore grow with event rate, subscriber count, and concurrent manager activity. No production impact has been observed.
Question
Would it make sense to retain one immutable connection-ID snapshot per listener and publish a replacement only on membership mutations, while publishing an empty snapshot at teardown so in-flight delivery cannot address stale connections?
I checked all relevant issues, comments, pull requests, discussions, and release notes; this report is not a duplicate.
I am reporting this finding only and am not proposing a pull request unless a maintainer invites one.
Disclosure
Investigated thoroughly with GPT-5.6 Sol (runtime-default reasoning effort), using Oh My Pi as the agent framework.
This report is not generic or unreviewed AI-generated output. Its claims were checked against the cited evidence, and it includes the relevant detail intended to help maintainers resolve the issue.
If reports like this are not useful to the project, please let me know and I will refrain from submitting similar ones. My intent is to help without wasting maintainer time or energy or discouraging their work.
Thank you for your work.