Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Use Range#size vs Range#count for uid-set limit #411

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Feb 26, 2025

(This PR is for v0.3-stable. v0.4 and v0.5 are unaffected.)

Prior to ruby 3.3, Range#count is handled by Enumerable#count, even for numeric ranges. For large ranges, Range#size is significantly faster. On my system, ruby 3.1 and 3.2 both took ~54 seconds (at 100% CPU) to run (1...2**32).count.

Range#count for numeric ranges is fast under ruby 3.3 and 3.4.

Thanks to @xiaoge1001 for reporting this issue (Fixes #410).

Prior to ruby 3.3, `Range#count` is handled by `Enumerable#count`, even
for numeric ranges.  For large ranges, `Range#size` is _significantly_
faster.  On my system, ruby 3.2 took 54 seconds (at 100% CPU) to run
`(1...2**32).count`.

Thanks to @xiaoge1001 for reporting this issue (#410).
@nevans nevans added bug Something isn't working backport This issue or PR is for a stable release branch labels Feb 26, 2025
@nevans nevans changed the title 🐛 Use Range#size vs Range#count for uid-set limit 🐛 Use Range#size vs Range#count for uid-set limit Feb 26, 2025
@nevans nevans merged commit c49ff9e into v0.3-stable Feb 26, 2025
34 checks passed
@nevans nevans deleted the uid-set-range-count branch February 26, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport This issue or PR is for a stable release branch bug Something isn't working
1 participant