phaistos-networks / TANK

A very high performance distributed log service
Apache License 2.0
938 stars 70 forks source link

Use a more appropriate timers tracking and scheduling scheme #50

Closed markpapadakis closed 4 years ago

markpapadakis commented 7 years ago

We now use a simple LL because there are usually no more than 100 or timers we need to check every few ms, and that's not a real concern, but this is far from optimal.

We should instead use either a hierarchical timerwheel or a simple heap/priority queue. Turns out go's using heaps, and O(1) for accessing the next timer to fire is a very desire properly, and given that all other operations cost O(log(n)) (no more than 14 ops for 10k timers), it makes a lot of sense to use binary heaps.