⚡ Bolt: Use borrowed BlockId in batch fetch#55
Conversation
Change the Storage trait's `get_block_outputs_batch` to accept references for BlockId, avoiding unnecessary String cloning in the engine's scheduler hot path. Co-authored-by: ovasylenko <3797513+ovasylenko@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. |
Change the Storage trait's `get_block_outputs_batch` to accept references for BlockId, avoiding unnecessary String cloning in the engine's scheduler hot path. Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
Change the Storage trait's `get_block_outputs_batch` to accept references for BlockId, avoiding unnecessary String cloning in the engine's scheduler hot path. Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
Change the Storage trait's `get_block_outputs_batch` to accept references for BlockId, avoiding unnecessary String cloning in the engine's scheduler hot path. Also fixes tests and fmt. Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
💡 What:
Updated the
Storagetrait'sget_block_outputs_batchsignature fromkeys: &[(InstanceId, BlockId)]tokeys: &[(InstanceId, &BlockId)]. Also updated the corresponding implementations in Postgres, SQLite, and Encrypting decorators, and replaced.clone()calls in the scheduler's deadline iteration hot-path with borrowing logic.🎯 Why:
To prevent allocating hundreds or thousands of Strings per tick. When preparing batch fetches for block outputs (especially related to SLAs/deadlines), the engine was mapping through sequence definitions and deeply cloning the
BlockIdstrings just to fulfill the trait's parameter type.📊 Impact:
Removes 1 heap allocation per block instance evaluation in the scheduler's
deadline_keyscollection logic, reducing GC/allocator pressure in the hot loop.🔬 Measurement:
Run
cargo run -p orch8-engineunder a profiler (likeflamegraph) or load testing scenario. The time spent in memory allocation within the scheduler loop (specifically related to building thedeadline_keysvector) should be measurably reduced. Validated correctness viacargo clippy -p orch8-storage -p orch8-engineandcargo test -p orch8-engine --lib scheduler::tests.PR created automatically by Jules for task 6193250396225194741 started by @ovasylenko