[PATCH 1/2] xlog: use ev_sleep instead of fiber_sleep for rate limiting

Vladimir Davydov vdavydov.dev at gmail.com
Mon Jun 4 12:51:33 MSK 2018


On Fri, Jun 01, 2018 at 08:52:55PM +0300, Konstantin Osipov wrote:
> * Vladimir Davydov <vdavydov.dev at gmail.com> [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?



More information about the Tarantool-patches mailing list