cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

Investigate replacing ScheduledExecutorService with a HashedWheelTimer

Open mpilquist opened this issue 4 years ago • 2 comments

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.

mpilquist avatar Jan 04 '21 16:01 mpilquist

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.

djspiewak avatar Jan 31 '21 04:01 djspiewak

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

TimWSpence avatar Feb 08 '21 11:02 TimWSpence

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.

He-Pin avatar Oct 10 '22 03:10 He-Pin

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

  • https://github.com/typelevel/cats-effect/discussions/3101
  • https://github.com/typelevel/cats-effect/discussions/3070

armanbilge avatar Oct 10 '22 03:10 armanbilge

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

  • https://github.com/typelevel/cats-effect/pull/3219

armanbilge avatar Feb 14 '23 01:02 armanbilge

@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)

He-Pin avatar Mar 10 '23 08:03 He-Pin