Skip to content

⚡ Bolt: Optimize $O(N^2)$ list inclusion checks in case extraction#87

Open
mapleleaflatte03 wants to merge 1 commit into
mainfrom
bolt-optimize-case-uniqueness-2464437084165330556
Open

⚡ Bolt: Optimize $O(N^2)$ list inclusion checks in case extraction#87
mapleleaflatte03 wants to merge 1 commit into
mainfrom
bolt-optimize-case-uniqueness-2464437084165330556

Conversation

@mapleleaflatte03
Copy link
Copy Markdown
Owner

💡 What: Refactored blocked_peer_host_ids and blocking_commitment_ids in kernel/kernel/cases.py and intelligence/company/meridian_platform/cases.py to use a set for ID tracking rather than a list.

🎯 Why: The original implementation used an $O(N)$ list inclusion check (not in seen) inside an $O(N)$ loop over blocking cases, resulting in an $O(N^2)$ algorithmic complexity. As the number of blocking cases grows, this repeated array scanning could significantly degrade runtime performance. Using a set brings the inclusion check down to $O(1)$ and avoids the quadratic scaling, returning the expected sorted list at the end.

📊 Impact: Reduces time complexity of unique value extraction from $O(N^2)$ to $O(N \log N)$ (due to sorting), providing measurable overhead reduction on case-heavy workspaces and preventing potential CPU saturation when iterating through hundreds of cases.

🔬 Measurement: Verified correctness by running existing test suites (kernel/kernel/tests/test_cases.py and intelligence/company/meridian_platform/test_cases.py), ensuring that standard functionality was preserved. Profiling scratchpads confirmed overhead reduction in array scanning loops.


PR created automatically by Jules for task 2464437084165330556 started by @mapleleaflatte03

Co-authored-by: mapleleaflatte03 <240846662+mapleleaflatte03@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant