ucx
ucx copied to clipboard
UCS: Rewrite timerq to use ucs_ptr_array_locked
What
This is a second attempt at #5094 : Currently, timerq implements a locked array internally, and this change rewrites timerq for it to use ucs_ptr_array_locked implementing a similar logic. This is the patch I mentioned in #5055 , and #4823 . It uses the "locked_ptr_array" introduced by @shuki-zanyovka in #4860 .
Why ?
Original motivation is from #4796 - Timer Queue extensions:
- Timer IDs switched from int to uint64_t
- Flags introduced, to support toggling unique/non-unique timer IDs in the queue
- Added a "removal hint", so that it's faster to remove a timer you previously added
How ?
This change leads to the following modifications:
- The timer_id is no longer set by the user of the timerq, but assigned by the ucs_ptr_array_locked and returned to the user.
- Due to the above async.c handler_id assignment was modified as follows:
- When adding a timer: the handler_id assigned to the timer handler is timer_id + UCS_ASYNC_TIMER_ID_MIN.
- When adding an event handler: the handler id is the event_fd as before
- The id retured to the caller is the handler_id (not the timer_id)
Credits
Most of the code was written by @tanyabrokhman, my changes were mostly made to rebase the code on top of the latest master.
Can one of the admins verify this patch?
ok to test
@alex--m is it possible to test this PR with the tests introduced in #5055? then we could close #5055 and just create a separate PR with those tests thanks!
@dmitrygx Yes, make sense to me. It's been a long time since I wrote this timerq code, so can't be 100% sure the tests fit the API changes, but I don't mind if the tests are submitted and I'll change this code accordingly.
waiting for #5609