From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 11/18] vinyl: use snap_io_rate_limit for initial dump bandwidth estimate Date: Thu, 16 Aug 2018 19:12:05 +0300 Message-Id: <111debb195d9c9780edef15d311ea94282a4fd60.1534432819.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: The user can limit dump bandwidth with box.cfg.snap_io_rate_limit to a value, which is less than the current estimate. To avoid stalls caused by overestimating dump bandwidth, we must take into account the limit for the initial guess and forget all observations whenever it changes. --- src/box/vinyl.c | 4 +++- src/box/vy_quota.c | 7 +++++++ src/box/vy_quota.h | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 8d315e87..3699fff8 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -2583,7 +2583,9 @@ vinyl_engine_set_too_long_threshold(struct vinyl_engine *vinyl, void vinyl_engine_set_snap_io_rate_limit(struct vinyl_engine *vinyl, double limit) { - vinyl->env->run_env.snap_io_rate_limit = limit * 1024 * 1024; + int64_t limit_in_bytes = limit * 1024 * 1024; + vinyl->env->run_env.snap_io_rate_limit = limit_in_bytes; + vy_quota_reset_dump_bw(&vinyl->env->quota, limit_in_bytes); } /** }}} Environment */ diff --git a/src/box/vy_quota.c b/src/box/vy_quota.c index 96f111f0..64c2ca04 100644 --- a/src/box/vy_quota.c +++ b/src/box/vy_quota.c @@ -171,6 +171,13 @@ vy_quota_set_limit(struct vy_quota *q, size_t limit) } void +vy_quota_reset_dump_bw(struct vy_quota *q, size_t max) +{ + histogram_reset(q->dump_bw_hist); + q->dump_bw = MIN(VY_DEFAULT_DUMP_BANDWIDTH, max); +} + +void vy_quota_force_use(struct vy_quota *q, size_t size) { q->used += size; diff --git a/src/box/vy_quota.h b/src/box/vy_quota.h index 33672a39..287c50f2 100644 --- a/src/box/vy_quota.h +++ b/src/box/vy_quota.h @@ -121,6 +121,13 @@ void vy_quota_set_limit(struct vy_quota *q, size_t limit); /** + * Reset dump bandwidth histogram and update initial estimate. + * Called when box.cfg.snap_io_rate_limit is updated. + */ +void +vy_quota_reset_dump_bw(struct vy_quota *q, size_t max); + +/** * Consume @size bytes of memory. In contrast to vy_quota_try_use() * this function does not throttle the caller. */ -- 2.11.0