From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 4 Jun 2018 12:51:33 +0300 From: Vladimir Davydov Subject: Re: [PATCH 1/2] xlog: use ev_sleep instead of fiber_sleep for rate limiting Message-ID: <20180604095133.iaxtdven3kjpuff5@esperanza> References: <6ac5f585085a3379daae90480c094412e67b4d2d.1527605229.git.vdavydov.dev@gmail.com> <20180601175255.GA15567@atlas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180601175255.GA15567@atlas> To: Konstantin Osipov Cc: tarantool-patches@freelists.org List-ID: On Fri, Jun 01, 2018 at 08:52:55PM +0300, Konstantin Osipov wrote: > * Vladimir Davydov [18/05/29 18:20]: > > fiber_sleep() works only if the current thread was created with > > cord_costart(). Since vinyl worker threads don't need fibers, they > > are created with cord_start() and hence can't use fiber_sleep(). > > So to be able to limit rate of vinyl dump/compaction, we have to > > use ev_sleep() instead of fiber_sleep() in xlog. This is fine by > > other xlog writers, because they don't use fibers either, neither > > they should as xlogs are written without coio. > > > > Needed for #3220 > > Please use cord_costart() in vinyl workers instead. For this to work, we would need to yield periodically (fiber_sleep(0)) while writing a run file. This would look weird as each worker thread executes just one task. Anyway, yielding in xlog_write() may be unexpected from caller's pov, because this function is blocking (writes a file) and isn't supposed to yield. One usually hands it over to coio or a worker thread, where yielding is pointless. > > We will end up needing it for other things and it's nearly free. What things?