Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 01/11] vinyl: merge vy_quota_release and vy_quota_update_dump_bandwidth
Date: Thu, 20 Sep 2018 12:34:06 +0300	[thread overview]
Message-ID: <f5e940a7e1e2a27c6cfd83ca4fc099be2aaa129e.1537435404.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1537435404.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1537435404.git.vdavydov.dev@gmail.com>

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

  reply	other threads:[~2018-09-20  9:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20  9:34 [PATCH 00/11] vinyl: prepare for transaction throttling Vladimir Davydov
2018-09-20  9:34 ` Vladimir Davydov [this message]
2018-09-20  9:34 ` [PATCH 02/11] vinyl: refactor quota use/unuse methods Vladimir Davydov
2018-09-20  9:34 ` [PATCH 03/11] vinyl: do not try to trigger dump if it is already in progress Vladimir Davydov
2018-09-20  9:34 ` [PATCH 04/11] vinyl: don't start quota timer until local recovery is complete Vladimir Davydov
2018-09-20  9:34 ` [PATCH 05/11] vinyl: add helper to start scheduler and enable quota on startup Vladimir Davydov
2018-09-25 23:22   ` [tarantool-patches] " Konstantin Osipov
2018-09-20  9:34 ` [PATCH 06/11] vinyl: zap vy_env::memory, read_threads, and write_threads Vladimir Davydov
2018-09-25 23:23   ` [tarantool-patches] " Konstantin Osipov
2018-09-20  9:34 ` [PATCH 07/11] vinyl: do not account zero dump bandwidth Vladimir Davydov
2018-09-25 23:24   ` [tarantool-patches] " Konstantin Osipov
2018-09-20  9:34 ` [PATCH 08/11] vinyl: set quota timer period to 100 ms Vladimir Davydov
2018-09-20  9:34 ` [PATCH 09/11] vinyl: implement basic transaction throttling Vladimir Davydov
2018-09-20  9:34 ` [PATCH 10/11] vinyl: implement quota wait queue without fiber_cond Vladimir Davydov
2018-09-20  9:34 ` [PATCH 11/11] vinyl: split quota consumption rate limit into soft and hard Vladimir Davydov
2018-09-25 23:19 ` [tarantool-patches] Re: [PATCH 00/11] vinyl: prepare for transaction throttling Konstantin Osipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5e940a7e1e2a27c6cfd83ca4fc099be2aaa129e.1537435404.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 01/11] vinyl: merge vy_quota_release and vy_quota_update_dump_bandwidth' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox