Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Cc: v.shpilevoy@tarantool.org
Subject: [Tarantool-patches] [PATCH v2 1/2] engine: add is_scheduled arg to engine->begin_checkpoint
Date: Tue, 28 Apr 2020 04:03:42 +0300	[thread overview]
Message-ID: <b70baf227690e3873457af1d1b72fbcb15800454.1588035071.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1588035071.git.korablev@tarantool.org>
In-Reply-To: <cover.1588035071.git.korablev@tarantool.org>

In some cases it may turn out to be useful to know whether checkpoint
process was launched manually (explicitly calling box.snapshot()) or
automatically via checkpoint daemon. In particular, to unthrottle vinyl
scheduler when it comes for manual checkpoints. So let's extend engine's
vtab method begin_checkpoint() with corresponding argument.

Needed for #3519
---
 src/box/engine.c       | 7 ++++---
 src/box/engine.h       | 6 +++---
 src/box/gc.c           | 8 ++++----
 src/box/memtx_engine.c | 3 ++-
 src/box/vinyl.c        | 3 ++-
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/box/engine.c b/src/box/engine.c
index 8dc0df1d0..88ed92861 100644
--- a/src/box/engine.c
+++ b/src/box/engine.c
@@ -129,11 +129,11 @@ engine_end_recovery(void)
 }
 
 int
-engine_begin_checkpoint(void)
+engine_begin_checkpoint(bool is_scheduled)
 {
 	struct engine *engine;
 	engine_foreach(engine) {
-		if (engine->vtab->begin_checkpoint(engine) < 0)
+		if (engine->vtab->begin_checkpoint(engine, is_scheduled) < 0)
 			return -1;
 	}
 	return 0;
@@ -356,9 +356,10 @@ generic_engine_end_recovery(struct engine *engine)
 }
 
 int
-generic_engine_begin_checkpoint(struct engine *engine)
+generic_engine_begin_checkpoint(struct engine *engine, bool is_scheduled)
 {
 	(void)engine;
+	(void)is_scheduled;
 	return 0;
 }
 
diff --git a/src/box/engine.h b/src/box/engine.h
index 07d7fac9b..c4da01e13 100644
--- a/src/box/engine.h
+++ b/src/box/engine.h
@@ -157,7 +157,7 @@ struct engine_vtab {
 	 * engine (snapshot is a memtx idea of a checkpoint).
 	 * Must not yield.
 	 */
-	int (*begin_checkpoint)(struct engine *);
+	int (*begin_checkpoint)(struct engine *, bool is_scheduled);
 	/**
 	 * Wait for a checkpoint to complete.
 	 */
@@ -354,7 +354,7 @@ void
 engine_complete_join(struct engine_join_ctx *ctx);
 
 int
-engine_begin_checkpoint(void);
+engine_begin_checkpoint(bool is_scheduled);
 
 /**
  * Create a checkpoint.
@@ -396,7 +396,7 @@ int generic_engine_begin_initial_recovery(struct engine *,
 					  const struct vclock *);
 int generic_engine_begin_final_recovery(struct engine *);
 int generic_engine_end_recovery(struct engine *);
-int generic_engine_begin_checkpoint(struct engine *);
+int generic_engine_begin_checkpoint(struct engine *, bool);
 int generic_engine_wait_checkpoint(struct engine *, const struct vclock *);
 void generic_engine_commit_checkpoint(struct engine *, const struct vclock *);
 void generic_engine_abort_checkpoint(struct engine *);
diff --git a/src/box/gc.c b/src/box/gc.c
index cbcdf7d12..8e8ffea75 100644
--- a/src/box/gc.c
+++ b/src/box/gc.c
@@ -377,7 +377,7 @@ gc_add_checkpoint(const struct vclock *vclock)
 }
 
 static int
-gc_do_checkpoint(void)
+gc_do_checkpoint(bool is_scheduled)
 {
 	int rc;
 	struct wal_checkpoint checkpoint;
@@ -389,7 +389,7 @@ gc_do_checkpoint(void)
 	 * Rotate WAL and call engine callbacks to create a checkpoint
 	 * on disk for each registered engine.
 	 */
-	rc = engine_begin_checkpoint();
+	rc = engine_begin_checkpoint(is_scheduled);
 	if (rc != 0)
 		goto out;
 	rc = wal_begin_checkpoint(&checkpoint);
@@ -436,7 +436,7 @@ gc_checkpoint(void)
 				gc.checkpoint_schedule.interval);
 	fiber_wakeup(gc.checkpoint_fiber);
 
-	if (gc_do_checkpoint() != 0)
+	if (gc_do_checkpoint(false) != 0)
 		return -1;
 
 	/*
@@ -506,7 +506,7 @@ gc_checkpoint_fiber_f(va_list ap)
 			 */
 			continue;
 		}
-		if (gc_do_checkpoint() != 0)
+		if (gc_do_checkpoint(true) != 0)
 			diag_log();
 	}
 	return 0;
diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index 4da80824a..394c5d974 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -619,8 +619,9 @@ fail:
 }
 
 static int
-memtx_engine_begin_checkpoint(struct engine *engine)
+memtx_engine_begin_checkpoint(struct engine *engine, bool is_scheduled)
 {
+	(void) is_scheduled;
 	struct memtx_engine *memtx = (struct memtx_engine *)engine;
 
 	assert(memtx->checkpoint == NULL);
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index ea4839dea..2a01322f7 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -2726,8 +2726,9 @@ vinyl_engine_set_snap_io_rate_limit(struct engine *engine, double limit)
 /* {{{ Checkpoint */
 
 static int
-vinyl_engine_begin_checkpoint(struct engine *engine)
+vinyl_engine_begin_checkpoint(struct engine *engine, bool is_scheduled)
 {
+	(void) is_scheduled;
 	struct vy_env *env = vy_env(engine);
 	assert(env->status == VINYL_ONLINE);
 	/*
-- 
2.17.1

  reply	other threads:[~2020-04-28  1:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  1:03 [Tarantool-patches] [PATCH v2 0/2] Unthrottle vinyl scheduler on manual checkpoint Nikita Pettik
2020-04-28  1:03 ` Nikita Pettik [this message]
2020-04-28  1:03 ` [Tarantool-patches] [PATCH v2 2/2] vinyl: unthrottle " Nikita Pettik
2020-05-03 17:01 ` [Tarantool-patches] [PATCH v2 0/2] Unthrottle vinyl " Vladislav Shpilevoy
2020-05-27 13:40   ` Nikita Pettik

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=b70baf227690e3873457af1d1b72fbcb15800454.1588035071.git.korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 1/2] engine: add is_scheduled arg to engine->begin_checkpoint' \
    /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