From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 24 Aug 2018 11:33:06 +0300 From: Vladimir Davydov Subject: Re: [PATCH 05/18] vinyl: wake up fibers waiting for quota one by one Message-ID: <20180824083306.o7gb5colm4rxhjrc@esperanza> References: <4938e95febbd96d464ebe8f8fdbb4c1785013e1f.1534432819.git.vdavydov.dev@gmail.com> <20180820111123.GH8716@chai> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180820111123.GH8716@chai> To: Konstantin Osipov Cc: tarantool-patches@freelists.org List-ID: On Mon, Aug 20, 2018 at 02:11:23PM +0300, Konstantin Osipov wrote: > * Vladimir Davydov [18/08/16 23:03]: > > Currently, we wake up all fibers whenever we free some memory. This > > is inefficient, because it might occur that all available quota gets > > consumed by a few fibers while the rest will have to go back to sleep. > > This is also kinda unfair, because waking up all fibers breaks the order > > in which the fibers were put to sleep. This works now, because we free > > memory and wake up fibers infrequently (on dump) and there normally > > shouldn't be any fibers waiting for quota (if there were, the latency > > would rocket sky high because of absence of any kind of throttling). > > However, once throttling is introduced, fibers waiting for quota will > > become the norm. So let's wake up fibers one by one: whenever we free > > memory we wake up the first fiber in the line, which will wake up the > > next fiber on success and so forth. > > + > > + /* Wake up the next fiber in the line waiting for quota. */ > > + fiber_cond_signal(&q->cond); > > return 0; > > Please only wake up the next fiber if there is one, or, better > yet, if this fiber had been put to sleep and then was woken up. I don't quite understand what you mean - fiber_cond_signal() will do nothing if there's no fiber waiting on it.