ucx icon indicating copy to clipboard operation
ucx copied to clipboard

UCS: Rewrite timerq to use ucs_ptr_array_locked

Open alex--m opened this issue 4 years ago • 5 comments

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:

  1. 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.
  2. 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.

alex--m avatar Aug 15 '20 16:08 alex--m

Can one of the admins verify this patch?

swx-jenkins3 avatar Aug 15 '20 16:08 swx-jenkins3

ok to test

shamisp avatar Aug 15 '20 16:08 shamisp

@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 avatar Aug 16 '20 13:08 dmitrygx

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

alex--m avatar Aug 19 '20 15:08 alex--m

waiting for #5609

alex--m avatar Aug 24 '20 10:08 alex--m