Skip to main content

Module hierarchical

Module hierarchical 

Source
Expand description

Hierarchical timer wheel (HHW). Three levels, each a wheel of 64 slots: seconds, minutes (each slot = 64 ticks), hours (each slot = 64*64 ticks). A timer scheduled d ticks out lands on the coarsest wheel whose slot can hold it; on each tick of a higher wheel we cascade its expiring slot’s entries down to the lower wheel re-binned at the residual offset.

Capacity: 64 * 64 * 64 = 262_144 ticks per “day” (loose analogy). Long delays no longer cost a no-op revolution per mask ticks the way the base wheel does; they sit on the coarse wheel and get cascaded down only as their fire time approaches.

Memory: 3 * 64 = 192 buckets total regardless of how many timers are scheduled - the buckets hold Vecs of entries, not a per-tick slot. Compare with the base single-level wheel which needs a slot count >= max-delay for O(1) firing.

Structs§

HierarchicalTimerWheel