⚡ Bolt: optimize Fisher-Yates shuffles in ransac.py#259
Conversation
This optimization improves the performance of `rand_permutation` and `rand_sample` by approximately 40-45%. Key changes: - Vectorized `stream.rand()` calls to pre-generate all necessary random numbers in a single call, reducing Python-to-C overhead. - Replaced the generic `round_mat` utility with `math.floor(x + 0.5)` for faster scalar "round half up" logic in the tight shuffle loop. - Maintained exact numerical parity with MATLAB's RNG consumption pattern, which is critical for ICA and RANSAC consistency. - Updated `.jules/bolt.md` performance journal. Co-authored-by: suraj-ranganath <14310165+suraj-ranganath@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. |
|
Claude finished @suraj-ranganath's task in 2m 13s —— View job PR Review: Optimize Fisher-Yates shuffles in
|
💡 What: Optimized
rand_permutationandrand_sampleinsrc/eegprep/plugins/clean_rawdata/private/ransac.pyby vectorizing random number generation and using faster scalar rounding logic.🎯 Why: These functions are core utilities for ICA and RANSAC, which are often the primary performance bottlenecks in EEG preprocessing pipelines.
📊 Impact: Measurable ~1.4x speedup (40-45% improvement) in shuffle operations while maintaining bit-exact reproducibility.
🔬 Measurement: Verified with a benchmark script measuring 100k-item permutations over multiple iterations and confirmed correctness with the full suite of RNG parity and ICA tests.
PR created automatically by Jules for task 13309992754005938132 started by @suraj-ranganath