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

Stop using a red black tree for the scheduler #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Geesu
Copy link

@Geesu Geesu commented Apr 12, 2024

The existing implementation of SortedSet asks each new timer to compare to other timers at the time of insertion and then places the object in the tree so it is sorted. Well, the workers gem is calculating the time remaining for a timer, but it never recalculates after the value is inserted into the tree.

This implementation evaluates sec_remaining when it accesses the set, which is required because the order is determined by that value, which changes over time. The previous implementation was not reevaluating these on insert, so the order would become more wrong over time.

Thx to ex-employee Robin for help debugging this weird ness!

@jharbert
Copy link
Member

@Geesu interesting - is this a bug in the Gem that was exposed via Ruby 3 upgrade?

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.

3 participants