[PATCH 06/18] vinyl: do not wake up fibers waiting for quota if quota is unavailable

Konstantin Osipov kostja at tarantool.org
Mon Aug 20 14:13:56 MSK 2018


* Vladimir Davydov <vdavydov.dev at gmail.com> [18/08/16 23:03]:
> There's no point to do that as they go back to sleep anyway. What is
> worse, such spurious wakeups may break the order in which fibers wait
> for quota.
> ---
>  src/box/vy_quota.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/src/box/vy_quota.c b/src/box/vy_quota.c
> index 3677e22e..8cea4deb 100644
> --- a/src/box/vy_quota.c
> +++ b/src/box/vy_quota.c
> @@ -56,6 +56,17 @@ enum {
>  	VY_QUOTA_RATE_AVG_PERIOD = 5,
>  };
>  
> +/**
> + * Wake up the next fiber in the line waiting for quota
> + * provided quota is available.
> + */
> +static inline void
> +vy_quota_signal(struct vy_quota *q)
> +{
> +	if (q->used < q->limit)
> +		fiber_cond_signal(&q->cond);
> +}

Meh, this makes it only more obscure. This kind of addresses my
previous comment, but takes the opposite approach: it relaxes the
wake up discipline by making sure there are no spurious wakeups.
You could add another check, e.g., that there are fibers waiting
in the line, and make vy_quota_signal() entirely foolproof. But
this doesn't answer the policy question: when should
vy_quota_siganl() be called? 

And as long as there is no clear answer to this question, it's
going to be called *everywhere*, just in case.

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