Use HHWheelTimer in the FiberManager
Summary: Currently, fibers library has its own class for managing timeouts - TimeoutController. It's optimized for the case when the set of timeouts is fixed and its size is not large. However, it's not efficient when that's not the case (see the benchmark). Since we're starting to use fibers in Thrift, we'll need to make sure that the underlying timeouts management is efficient for unbounded cases. This kills `TimeoutController` and switches FiberManager to use `HHWheelTimer` from the underlying LoopController (which is in general EventBase). One important note is that `HHWheelTimer` is **not exact** it rounds up timeouts to the 10ms boundary, so this **will slightly change the behavior**. The results of FibersBenchmark before & after: Before: ``` ============================================================================ folly/fibers/test/FibersBenchmark.cpp relative time/iter iters/s ============================================================================ FiberManagerCancelledTimeouts_Single_300 16.34ms 61.18 FiberManagerCancelledTimeouts_Five 17.54ms 57.00 FiberManagerCancelledTimeouts_TenThousand 252.06ms 3.97 ============================================================================ ``` After: ``` ============================================================================ folly/fibers/test/FibersBenchmark.cpp relative time/iter iters/s ============================================================================ FiberManagerCancelledTimeouts_Single_300 22.75ms 43.95 FiberManagerCancelledTimeouts_Five 21.12ms 47.34 FiberManagerCancelledTimeouts_TenThousand 19.13ms 52.27 ============================================================================ ``` This shows that with HHWheelTimer, throughput is unaffected by the number of different values used. Reviewed By: andriigrynenko Differential Revision: D13613830 fbshipit-source-id: 7b4662d308a9e1ef232672338a78b79efba46172
Showing
Please register or sign in to comment