typelevel / cats-effect

The pure asynchronous runtime for Scala
https://typelevel.org/cats-effect/
Apache License 2.0
2.02k stars 517 forks source link

Investigate replacing ScheduledExecutorService with a HashedWheelTimer #1580

Closed mpilquist closed 1 year ago

mpilquist commented 3 years ago

Netty, Akka, Blaze, and other libraries all use a variant of a hash wheel timer for scheduling lots of non-blocking tasks:

https://stackoverflow.com/questions/17276393/hashedwheeltimer-vs-scheduledthreadpoolexecutor-for-higher-performance

We should consider adopting something similar for CE3, measured against ScheduledExecutorService to see which is better. At the very least, we should ensure there are no API changes necessary if we later want to swap in a custom scheduler.

djspiewak commented 3 years ago

Based on what I can find, this is definitely something that is worth doing. If we can get it in for 3.0, it would be ideal, but it's technically something that can land afterward if necessary.

TimWSpence commented 3 years ago

This looks fun! Happy to have a stab at it at least

He-Pin commented 2 years ago

I think this is really needed. I was fired an issue https://github.com/reactor/reactor-core/issues/2965 and switch to Akka just because of this.

armanbilge commented 2 years ago

@He-Pin see the following discussions regarding plans for 3.5.0:

armanbilge commented 1 year ago

Not a hashwheel timer, but still a replacement for ScheduledExecutorService.

He-Pin commented 1 year ago

@armanbilge @djspiewak I think this need renmaed to add a HashedWheelTimer to cats-effect

because the current integrated timer is O(log N), not O(1)