Skip to content

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When receiving a large uid set, net-imap will consume a significant amount of CPU resources and take long time to raise ResponseParseError.

2 participants