Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 1/2] gc: use wide integer for schedule counting
Date: Sun, 14 Mar 2021 21:24:46 +0300	[thread overview]
Message-ID: <YE5U7pO8sgS9sdHQ@grain> (raw)
In-Reply-To: <22029d0a-d7b1-ccb6-b928-a7e277e034c0@tarantool.org>

On Sun, Mar 14, 2021 at 05:30:57PM +0100, Vladislav Shpilevoy wrote:
> > -		assert(delta > 0);
> >  		gc_run_cleanup();
> >  		gc.cleanup_completed += delta;
> > +		assert(delta > 0 && gc.cleanup_completed > 0);
> 
> You didn't need to change the assertion. If `delta` is always
> positive, and `cleanup_completed` is populated only from `delta`,
> it is also positive always.

This allows to make sure that gc.cleanup_completed didn't
change in gc_run_cleanup in unpredicted way. I'll update
if you prefer, sure thing. Force pushed.
---
diff --git a/src/box/gc.c b/src/box/gc.c
index 1f8cc818d..9af4ef958 100644
--- a/src/box/gc.c
+++ b/src/box/gc.c
@@ -239,7 +239,7 @@ gc_cleanup_fiber_f(va_list ap)
 {
 	(void)ap;
 	while (!fiber_is_cancelled()) {
-		int delta = gc.cleanup_scheduled - gc.cleanup_completed;
+		int64_t delta = gc.cleanup_scheduled - gc.cleanup_completed;
 		if (delta == 0) {
 			/* No pending garbage collection. */
 			fiber_sleep(TIMEOUT_INFINITY);
@@ -278,7 +278,7 @@ gc_schedule_cleanup(void)
 static void
 gc_wait_cleanup(void)
 {
-	unsigned scheduled = gc.cleanup_scheduled;
+	int64_t scheduled = gc.cleanup_scheduled;
 	while (gc.cleanup_completed < scheduled)
 		fiber_cond_wait(&gc.cleanup_cond);
 }
diff --git a/src/box/gc.h b/src/box/gc.h
index 829aaf479..2a568c5f9 100644
--- a/src/box/gc.h
+++ b/src/box/gc.h
@@ -146,7 +146,7 @@ struct gc_state {
 	 * sleep until @completed reaches the value of @scheduled
 	 * taken at that moment of time.
 	 */
-	unsigned cleanup_completed, cleanup_scheduled;
+	int64_t cleanup_completed, cleanup_scheduled;
 	/**
 	 * Set if there's a fiber making a checkpoint right now.
 	 */
-- 
2.30.2


  reply	other threads:[~2021-03-14 18:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 20:47 [Tarantool-patches] [PATCH 0/2] A few fixes for gc and xlog Cyrill Gorcunov via Tarantool-patches
2021-03-10 20:47 ` [Tarantool-patches] [PATCH 1/2] gc: use wide integer for schedule counting Cyrill Gorcunov via Tarantool-patches
2021-03-14 16:30   ` Vladislav Shpilevoy via Tarantool-patches
2021-03-14 18:24     ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-03-10 20:47 ` [Tarantool-patches] [PATCH 2/2] xlog: do not sort sole entry Cyrill Gorcunov via Tarantool-patches
2021-03-12 17:11 ` [Tarantool-patches] [PATCH 0/2] A few fixes for gc and xlog Serge Petrenko via Tarantool-patches
2021-03-12 17:45   ` Cyrill Gorcunov via Tarantool-patches
2021-03-15 23:21 ` Vladislav Shpilevoy via Tarantool-patches
2021-03-16 13:29 ` Kirill Yukhin via Tarantool-patches

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=YE5U7pO8sgS9sdHQ@grain \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/2] gc: use wide integer for schedule counting' \
    /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