From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 20 Aug 2018 14:13:56 +0300 From: Konstantin Osipov Subject: Re: [PATCH 06/18] vinyl: do not wake up fibers waiting for quota if quota is unavailable Message-ID: <20180820111356.GI8716@chai> References: <60779b34e52b0761aea836492370fd8b11ff68df.1534432819.git.vdavydov.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60779b34e52b0761aea836492370fd8b11ff68df.1534432819.git.vdavydov.dev@gmail.com> To: Vladimir Davydov Cc: tarantool-patches@freelists.org List-ID: * Vladimir Davydov [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