[tarantool-patches] Re: [PATCH v2 05/11] vinyl: implement quota wait queue without fiber_cond
Konstantin Osipov
kostja at tarantool.org
Sat Sep 29 08:05:31 MSK 2018
* Vladimir Davydov <vdavydov.dev at gmail.com> [18/09/28 21:00]:
> Using fiber_cond as a wait queue isn't very convenient, because:
> - It doesn't allow us to put a spuriously woken up fiber back to the
> same position in the queue where it was, thus violating fairness.
> - It doesn't allow us to check whether we actually need to wake up a
> fiber or it will have to go back to sleep anyway as it needs more
> memory than currently available.
> - It doesn't allow us to implement a multi-queue approach where fibers
> that have different priorities are put to different queues.
>
> So let's rewrite the wait queue with plain rlist and fiber_yield.
Maybe you could factor out this change into an abstraction in fiber.[hc]?
Or fix fiber_cond to be fair?
>
> @@ -92,7 +91,17 @@ vy_quota_check_limit(struct vy_quota *q)
> static void
> vy_quota_signal(struct vy_quota *q)
> {
> - fiber_cond_signal(&q->cond);
> + if (!rlist_empty(&q->wait_queue)) {
> + struct vy_quota_wait_node *n;
> + n = rlist_first_entry(&q->wait_queue,
> + struct vy_quota_wait_node, in_wait_queue);
> + /*
> + * No need in waking up a consumer if it will have
> + * to go back to sleep immediately.
> + */
> + if (vy_quota_may_use(q, n->size))
> + fiber_wakeup(n->fiber);
> + }
> }
--
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov
More information about the Tarantool-patches
mailing list