⚡ Bolt: optimize random number generation performance#94
Conversation
- Implement hybrid strategy: rejection sampling for low density, Sparse Fisher-Yates for high density (>= 50%). - Replace innerText with textContent for faster DOM updates. - Add 10,000,000 range size safety limit. - Update CSS to handle large result sets (max-height, overflow, word-break). Performance impact: ~17x speedup for internal logic in high-density cases (e.g., 999,999 numbers in 1,000,000 range). Co-authored-by: babelman97 <[email protected]>
|
👋 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. |
This PR optimizes the unique random number generation in
random.html.💡 What
🎯 Why
The original implementation used rejection sampling (Set-based), which performs$O(N^2+)$ in high-density scenarios because of frequent collisions. For a request of 999,999 numbers in a 1,000,000 range, this could take over 8 seconds or hang the browser.
📊 Impact
🔬 Measurement
Verified using a Playwright-based benchmark script measuring
performance.now()inside the browser context before and after the optimization. Visual integrity verified with Playwright screenshots for both small and large output sets.PR created automatically by Jules for task 4496981776660765217 started by @babelman97