⚡ Bolt: Zero-allocation vector filtering in concurrency hot path - #93
Conversation
|
👋 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. |
Replaced the `into_iter().enumerate().filter().collect()` pattern in `filter_by_concurrency` (SQLite) and `filter_by_concurrency_pg` (Postgres) with `Vec::retain()` using an external counter. This avoids unnecessary memory allocations and buffer reallocations on the instance scheduling hot path. Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
Replaced the `into_iter().enumerate().filter().collect()` pattern in `filter_by_concurrency` (SQLite) and `filter_by_concurrency_pg` (Postgres) with `Vec::retain()` using an external counter. This avoids unnecessary memory allocations and buffer reallocations on the instance scheduling hot path. Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
f3958b6 to
a3cb34d
Compare
💡 What: Replaced out-of-place vector filtering (
into_iter().enumerate().filter().collect()) with in-place mutation (retain()) infilter_by_concurrencyandfilter_by_concurrency_pg.🎯 Why:
filter_by_concurrencyoperates directly on a vector passed by value in the scheduler execution hot path. Re-collecting elements forces a new buffer allocation and moves memory unnecessarily.📊 Impact: Eliminates a
Vecmemory allocation and buffer copy per batch in theclaim_due_instancespath, improving memory stability during heavy scheduling load.🔬 Measurement: Verify with
cargo test -p orch8-storage. Code operates exactly as before but with zero reallocation overhead.PR created automatically by Jules for task 14725430113395233040 started by @ovasylenko