From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 01/11] vinyl: merge vy_quota_release and vy_quota_update_dump_bandwidth Date: Thu, 20 Sep 2018 12:34:06 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: These functions are always called together when memory dump is complete. Soon we will also have to update throttle rate limit there too. Let's merge them now and call the resulting function vy_quota_dump to reflect the fact that it's only called on dump by design. While we are at it, remove vy_quota_dump_bandwidth() declaration as this function isn't defined or used anywhere. --- src/box/vinyl.c | 3 +-- src/box/vy_quota.c | 20 ++++++++++---------- src/box/vy_quota.h | 16 +++------------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index b5904872..6cc5485b 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -2467,8 +2467,7 @@ vy_env_dump_complete_cb(struct vy_scheduler *scheduler, size_t mem_used_after = lsregion_used(allocator); assert(mem_used_after <= mem_used_before); size_t mem_dumped = mem_used_before - mem_used_after; - vy_quota_release(quota, mem_dumped); - vy_quota_update_dump_bandwidth(quota, mem_dumped, dump_duration); + vy_quota_dump(quota, mem_dumped, dump_duration); say_info("dumped %zu bytes in %.1f sec", mem_dumped, dump_duration); } diff --git a/src/box/vy_quota.c b/src/box/vy_quota.c index 51f0ba71..d3588b6e 100644 --- a/src/box/vy_quota.c +++ b/src/box/vy_quota.c @@ -170,9 +170,17 @@ vy_quota_set_limit(struct vy_quota *q, size_t limit) } void -vy_quota_update_dump_bandwidth(struct vy_quota *q, size_t size, - double duration) +vy_quota_dump(struct vy_quota *q, size_t size, double duration) { + /* + * Release quota and wake up the first fiber in + * the wait queue, if any. + */ + assert(q->used >= size); + q->used -= size; + fiber_cond_signal(&q->cond); + + /* Update dump bandwidth. */ if (duration > 0) { histogram_collect(q->dump_bw_hist, size / duration); /* @@ -201,14 +209,6 @@ vy_quota_force_use(struct vy_quota *q, size_t size) q->quota_exceeded_cb(q); } -void -vy_quota_release(struct vy_quota *q, size_t size) -{ - assert(q->used >= size); - q->used -= size; - fiber_cond_signal(&q->cond); -} - int vy_quota_use(struct vy_quota *q, size_t size, double timeout) { diff --git a/src/box/vy_quota.h b/src/box/vy_quota.h index 9ce53fc4..0fa852b1 100644 --- a/src/box/vy_quota.h +++ b/src/box/vy_quota.h @@ -120,19 +120,15 @@ vy_quota_destroy(struct vy_quota *q); void vy_quota_set_limit(struct vy_quota *q, size_t limit); -/** Return dump bandwidth. */ -size_t -vy_quota_dump_bandwidth(struct vy_quota *q); - /** - * Update dump bandwidth. + * Function called on dump completion to release quota after + * freeing memory. * * @size: size of dumped memory. * @duration: how long memory dump took. */ void -vy_quota_update_dump_bandwidth(struct vy_quota *q, size_t size, - double duration); +vy_quota_dump(struct vy_quota *q, size_t size, double duration); /** * Reset dump bandwidth histogram and update initial estimate. @@ -149,12 +145,6 @@ void vy_quota_force_use(struct vy_quota *q, size_t size); /** - * Release @size bytes of memory. - */ -void -vy_quota_release(struct vy_quota *q, size_t size); - -/** * Try to consume @size bytes of memory, throttle the caller * if the limit is exceeded. @timeout specifies the maximal * time to wait. Return 0 on success, -1 on timeout. -- 2.11.0