From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH v3 2/4] vinyl: remove extra quota check from vy_quota_use
Date: Tue, 12 Feb 2019 20:26:54 +0300 [thread overview]
Message-ID: <1762d22b6826352d5dc1a3e8bb3a2b3e6026f5d7.1549990576.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1549990576.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1549990576.git.vdavydov.dev@gmail.com>
Before waking up a fiber that is waiting for quota, we always first
check if it can actually consume it, see vy_quota_signal. Hence the
extra check in vy_quota_use is needed only to prevent spurious wakeups.
It doesn't seem to be wise to add such a check to a hot path as a
counter-mesaure to such an unlikely scenario. Let's remove it - after
all it isn't critical if a spuriously woken up fiber exceeds the limit.
---
src/box/vy_quota.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/box/vy_quota.c b/src/box/vy_quota.c
index dc452adb..7d59e20d 100644
--- a/src/box/vy_quota.c
+++ b/src/box/vy_quota.c
@@ -294,27 +294,20 @@ vy_quota_use(struct vy_quota *q, enum vy_quota_consumer_type type,
/* Wait for quota. */
double wait_start = ev_monotonic_now(loop());
- double deadline = wait_start + timeout;
-
struct vy_quota_wait_node wait_node = {
.fiber = fiber(),
.size = size,
.ticket = ++q->wait_ticket,
};
rlist_add_tail_entry(&q->wait_queue[type], &wait_node, in_wait_queue);
-
- do {
- double now = ev_monotonic_now(loop());
- fiber_yield_timeout(deadline - now);
- if (now >= deadline) {
- rlist_del_entry(&wait_node, in_wait_queue);
- diag_set(ClientError, ER_VY_QUOTA_TIMEOUT);
- return -1;
- }
- } while (!vy_quota_may_use(q, type, size));
-
+ bool timed_out = fiber_yield_timeout(timeout);
rlist_del_entry(&wait_node, in_wait_queue);
+ if (timed_out) {
+ diag_set(ClientError, ER_VY_QUOTA_TIMEOUT);
+ return -1;
+ }
+
double wait_time = ev_monotonic_now(loop()) - wait_start;
if (wait_time > q->too_long_threshold) {
say_warn_ratelimited("waited for %zu bytes of vinyl memory "
--
2.11.0
next prev parent reply other threads:[~2019-02-12 17:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 17:26 [PATCH v3 0/4] vinyl: compaction randomization and throttling Vladimir Davydov
2019-02-12 17:26 ` [PATCH v3 1/4] vinyl: introduce quota consumer types Vladimir Davydov
2019-02-12 18:14 ` Konstantin Osipov
2019-02-12 17:26 ` Vladimir Davydov [this message]
2019-02-12 18:15 ` [PATCH v3 2/4] vinyl: remove extra quota check from vy_quota_use Konstantin Osipov
2019-02-12 17:26 ` [PATCH v3 3/4] vinyl: don't consume quota if wait queue isn't empty Vladimir Davydov
2019-02-12 18:15 ` Konstantin Osipov
2019-02-12 17:26 ` [PATCH v3 4/4] vinyl: throttle tx to ensure compaction keeps up with dumps Vladimir Davydov
2019-02-12 18:20 ` Konstantin Osipov
2019-02-13 10:56 ` [PATCH v3 0/4] vinyl: compaction randomization and throttling Vladimir Davydov
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=1762d22b6826352d5dc1a3e8bb3a2b3e6026f5d7.1549990576.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH v3 2/4] vinyl: remove extra quota check from vy_quota_use' \
/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