[Repo Assist] perf: single-pass Remove(key, out value) for pending-request dictionaries#722
Conversation
…ionaries TakePendingRequestMethod and TakePendingChatSend previously used two separate dictionary operations: TryGetValue to retrieve the value, followed by Remove to delete the entry — two hash lookups per call. Replace both with Dictionary.Remove(TKey, out TValue) which resolves the key only once and returns the removed value atomically under the existing lock. Both methods are on the receive hot path: called for every incoming gateway response message and every chat.send result. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Codex review: needs maintainer review before merge. Reviewed June 8, 2026, 10:08 AM ET / 14:08 UTC. Summary Reproducibility: not applicable. this is a cleanup/performance PR, not a bug report with a failing runtime scenario. Source inspection confirms the old two-step lookup/remove pattern exists on current main. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow cleanup after repo-required validation is completed or accepted by maintainers for this automation PR. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a cleanup/performance PR, not a bug report with a failing runtime scenario. Source inspection confirms the old two-step lookup/remove pattern exists on current main. Is this the best way to solve the issue? Yes: for AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 37b0ea672037. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Replace double-lookup
TryGetValue + Removewith the single-passDictionary.Remove(TKey, out TValue)overload in two gateway-client hot-path methods.Rationale
Both
TakePendingRequestMethodandTakePendingChatSendare called for every incoming WebSocket response message — a high-frequency path under a lock. The previous implementation performed two separate hash-table lookups:Dictionary<K,V>.Remove(K, out V)(available since .NET Core 2.0) resolves the key once and removes the entry in the same operation:This also reduces the method body from 4–5 lines to 1 line under the lock, improving readability.
Scope
TakePendingRequestMethod— called on every"res"type message (all gateway responses)TakePendingChatSend— called on every response, attempting to match a pending chat.sendNo behaviour change; the
ConcurrentDictionary-based_pendingWizardResponsesalready usedTryRemove(equivalent single-pass) and is unchanged.Test Status
./build.ps1): GitVersion MSBuild task requiresGITHUB_ENV(pre-existing infrastructure limitation in agent environment)Add this agentic workflows to your repo
To install this agentic workflow, run