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

Vladimir Davydov vdavydov.dev at gmail.com
Tue May 29 18:19:36 MSK 2018


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
---
 src/box/xlog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/box/xlog.c b/src/box/xlog.c
index af79e324..be7b3459 100644
--- a/src/box/xlog.c
+++ b/src/box/xlog.c
@@ -1090,7 +1090,7 @@ xlog_tx_write(struct xlog *log)
 			throttle_time = (double)sync_len / log->rate_limit -
 					(ev_monotonic_time() - log->sync_time);
 			if (throttle_time > 0)
-				fiber_sleep(throttle_time);
+				ev_sleep(throttle_time);
 		}
 		/** sync data from cache to disk */
 #ifdef HAVE_SYNC_FILE_RANGE
-- 
2.11.0




More information about the Tarantool-patches mailing list