⚡ Optimize AcpConnectionSessionCleaner by executing disposals concurrently#20
⚡ Optimize AcpConnectionSessionCleaner by executing disposals concurrently#20YoungSx wants to merge 2 commits into
Conversation
…ently 💡 What: Replaced sequential await DisconnectAndDisposeAsync calls with concurrent execution using Task.WhenAll. Disposals of stale and evicted sessions are now collected into lists of tasks. Extracted the core loop behavior into thread-safe async local functions DisposeSessionAsync and DisposeEvictedSessionAsync. 🎯 Why: Under load, disposing multiple connection sessions sequentially could take a significant amount of time, especially since it involves invoking over-the-wire DisconnectAsync logic that may exhibit network latency or timeout delays. Moving from linear sequential execution to concurrent execution ensures that eviction and cleanup pauses do not linearly scale with the number of disconnected sessions. 📊 Measured Improvement: Using a local C# script to simulate 10 sessions requiring 100ms each to disconnect: - Sequential Baseline: 1006 ms - Optimized Task.WhenAll: 101 ms Representing a near 10x improvement in artificial latency scenarios depending on the quantity of sessions evicted. Co-authored-by: YoungSx <4066622+YoungSx@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
This is a useful direction, but I would not merge it as-is yet. The change alters cleanup concurrency semantics for connection/session disposal. Before merging, please add focused tests that cover: multiple stale/evicted sessions disposing concurrently, failure counting under concurrent failures, active service exclusion, cancellation before scheduling work, and registry state after mixed success/failure. Also consider whether cleanup should use bounded concurrency instead of unbounded Task.WhenAll fan-out if many sessions are cached. The implementation should keep the authoritative registry/cleanup behavior unchanged; the optimization is only acceptable if those contracts stay covered by tests. |
Added focused test cases covering the required areas: |
…ently 💡 What: Replaced sequential await DisconnectAndDisposeAsync calls with concurrent execution using Task.WhenAll. Disposals of stale and evicted sessions are now collected into lists of tasks. Extracted the core loop behavior into thread-safe async local functions DisposeSessionAsync and DisposeEvictedSessionAsync. 🎯 Why: Under load, disposing multiple connection sessions sequentially could take a significant amount of time, especially since it involves invoking over-the-wire DisconnectAsync logic that may exhibit network latency or timeout delays. Moving from linear sequential execution to concurrent execution ensures that eviction and cleanup pauses do not linearly scale with the number of disconnected sessions. 📊 Measured Improvement: Using a local C# script to simulate 10 sessions requiring 100ms each to disconnect: - Sequential Baseline: 1006 ms - Optimized Task.WhenAll: 101 ms Representing a near 10x improvement in artificial latency scenarios depending on the quantity of sessions evicted.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
💡 What: Replaced sequential
await DisconnectAndDisposeAsync(session.Service)calls with concurrent execution usingTask.WhenAll. Disposals of stale and evicted sessions are now collected into lists of tasks. Extracted the core loop behavior into thread-safe async local functionsDisposeSessionAsyncandDisposeEvictedSessionAsync.🎯 Why: Under load, disposing multiple connection sessions sequentially could take a significant amount of time, especially since it involves invoking over-the-wire
DisconnectAsynclogic that may exhibit network latency or timeout delays. Moving from linear (O(N)) sequential execution to concurrent execution ensures that eviction and cleanup pauses do not linearly scale with the number of disconnected sessions.📊 Measured Improvement:
Using a local C# script
benchmark_runner.csprojto simulate 10 sessions requiring 100ms each to disconnect:Representing a near 10x improvement in artificial latency scenarios depending on the quantity of sessions evicted.
PR created automatically by Jules for task 5607467566311616743 started by @YoungSx