⚡ perf: Optimize high concurrency test by wrapping payload in Arc#135
⚡ perf: Optimize high concurrency test by wrapping payload in Arc#135panayang wants to merge 1 commit into
Conversation
Avoid expensive Vec clone in no-batching high concurrency test loops by wrapping `encoded` payload in an `Arc`. This avoids massively allocating when spawning concurrent async tasks. Performance measurement (release mode): Before: batching: 612166.94 tasks/sec (8.17s) no batching: 212024.57 tasks/sec (23.58s) After: batching: 881996.51 tasks/sec (5.67s) -> ~44% improvement no batching: 637342.51 tasks/sec (7.85s) -> ~200% improvement Co-authored-by: panayang <223123845+panayang@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. |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
💡 What:
Replaced
Vec<u8>withArc<Vec<u8>>for theencodedpayload intests/high_concurrency.rs. This involved updatingPartialReader'sdatafield andrun_worker's argument type, along with wrapping the serialized payload in anArcinside both test functions.🎯 Why:
The high concurrency test was performing a deep clone of the
encodedpayload vector inside the task spawning loop (encoded.clone()). In a tight loop spawning 5,000,000 tasks, this leads to massive, expensive memory allocations that drastically affect performance. Wrapping the payload in anArc(Atomic Reference Count) ensures only the reference count is incremented upon cloning, avoiding deep copies of the byte array and saving significant CPU and memory allocation overhead.📊 Measured Improvement:
Running
cargo test --release --test high_concurrencybefore and after the change showed significant performance improvements:Baseline:
After Optimization:
PR created automatically by Jules for task 13273604940859237615 started by @panayang