From: Georgy Kirichenko <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Georgy Kirichenko <georgy@tarantool.org>
Subject: [tarantool-patches] [PATCH v2 6/8] Offload tx_prio processing to a fiber
Date: Thu, 23 May 2019 11:19:38 +0300 [thread overview]
Message-ID: <7ea0167cb98532c99905f74be0c07a95ead02d04.1558598679.git.georgy@tarantool.org> (raw)
In-Reply-To: <cover.1558598679.git.georgy@tarantool.org>
---
src/box/box.cc | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/box/box.cc b/src/box/box.cc
index e10b73277..b8ef4b9ed 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -2061,13 +2061,41 @@ local_recovery(const struct tt_uuid *instance_uuid,
}
}
+/* A structure containing tx_prio endpoint fiber context. */
+static struct tx_prio_ctx {
+ /* The fiber processing the tx_prio endpoint. */
+ struct fiber *fiber;
+ /* True if there are more messages to process. */
+ bool has_message;
+ /* Condition to signal when a new message arrived. */
+ struct fiber_cond message_cond;
+} tx_prio_ctx;
+
static void
tx_prio_cb(struct ev_loop *loop, ev_watcher *watcher, int events)
{
(void) loop;
(void) events;
- struct cbus_endpoint *endpoint = (struct cbus_endpoint *)watcher->data;
- cbus_process(endpoint);
+ (void) watcher;
+ tx_prio_ctx.has_message = true;
+ fiber_cond_signal(&tx_prio_ctx.message_cond);
+}
+
+/*
+ * Tx prio endpoint fiber function.
+ */
+static int
+tx_prio_process_f(va_list ap)
+{
+ (void) ap;
+ while (!fiber_is_cancelled()) {
+ while (tx_prio_ctx.has_message) {
+ tx_prio_ctx.has_message = false;
+ cbus_process(&tx_prio_endpoint);
+ }
+ fiber_cond_wait(&tx_prio_ctx.message_cond);
+ }
+ return 0;
}
static void
@@ -2119,6 +2147,12 @@ box_cfg_xc(void)
IPROTO_MSG_MAX_MIN * IPROTO_FIBER_POOL_SIZE_FACTOR,
FIBER_POOL_IDLE_TIMEOUT);
/* Add an extra endpoint for WAL wake up/rollback messages. */
+ memset(&tx_prio_ctx, 0, sizeof(struct tx_prio_ctx));
+ fiber_cond_create(&tx_prio_ctx.message_cond);
+ tx_prio_ctx.fiber = fiber_new("tx_prio", tx_prio_process_f);
+ if (tx_prio_ctx.fiber == NULL)
+ panic("Could not create tx_prio fiber");
+ fiber_start(tx_prio_ctx.fiber, NULL);
cbus_endpoint_create(&tx_prio_endpoint, "tx_prio", tx_prio_cb, &tx_prio_endpoint);
rmean_box = rmean_new(iproto_type_strs, IPROTO_TYPE_STAT_MAX);
--
2.21.0
next prev parent reply other threads:[~2019-05-23 8:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 8:19 [tarantool-patches] [PATCH v2 0/8] Make transaction autonomous from a fiber internals Georgy Kirichenko
2019-05-23 8:19 ` [tarantool-patches] [PATCH v2 1/8] Encode a dml statement to a transaction memory region Georgy Kirichenko
2019-05-28 1:21 ` [tarantool-patches] " Kirill Yukhin
2019-05-23 8:19 ` [tarantool-patches] [PATCH v2 2/8] Get rid of autocommit from a txn structure Georgy Kirichenko
2019-05-27 20:51 ` [tarantool-patches] " Konstantin Osipov
2019-05-31 19:21 ` Konstantin Osipov
2019-05-23 8:19 ` [tarantool-patches] [PATCH v2 3/8] Get rid of fiber_gc from txn_rollback Georgy Kirichenko
2019-05-31 19:27 ` [tarantool-patches] " Konstantin Osipov
2019-05-23 8:19 ` [tarantool-patches] [PATCH v2 4/8] Remove fiber from a journal_entry structure Georgy Kirichenko
2019-05-31 19:29 ` [tarantool-patches] " Konstantin Osipov
2019-05-23 8:19 ` [tarantool-patches] [PATCH v2 5/8] Commit engine before all triggers Georgy Kirichenko
2019-05-31 19:32 ` [tarantool-patches] " Konstantin Osipov
2019-06-03 8:07 ` Георгий Кириченко
2019-05-23 8:19 ` Georgy Kirichenko [this message]
2019-05-31 19:36 ` [tarantool-patches] Re: [PATCH v2 6/8] Offload tx_prio processing to a fiber Konstantin Osipov
2019-06-03 8:04 ` Георгий Кириченко
2019-05-23 8:19 ` [tarantool-patches] [PATCH v2 7/8] Enable asyncronous wal writes Georgy Kirichenko
2019-05-31 19:41 ` [tarantool-patches] " Konstantin Osipov
2019-06-03 8:09 ` Георгий Кириченко
2019-05-23 8:19 ` [tarantool-patches] [PATCH v2 8/8] Introduce asynchronous txn commit Georgy Kirichenko
2019-05-31 19:43 ` [tarantool-patches] " 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=7ea0167cb98532c99905f74be0c07a95ead02d04.1558598679.git.georgy@tarantool.org \
--to=georgy@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH v2 6/8] Offload tx_prio processing to a fiber' \
/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