From a35425862c85a4b67b81a498e3788dda6f15587b Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov.dev@gmail.com>
Date: Thu, 4 Oct 2018 17:28:41 +0300
Subject: [PATCH] gc: call gc_run unconditionally when consumer is advanced

gc_consumer_unregister and gc_consumer_advance don't call gc_run in case
the consumer in question isn't leftmost. This code was written back when
gc_run was kinda heavy and would call engine/wal callbacks even if it
wouldn't really need to. Today gc_run will bail out shortly, without
making any complex computation, let alone invoking garbage collection
callbacks, in case it has nothing to do so those optimizations are
pointless. Let's remove them.
---
 src/box/gc.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/src/box/gc.c b/src/box/gc.c
index 4ebf68437b..becb5d09da 100644
--- a/src/box/gc.c
+++ b/src/box/gc.c
@@ -279,18 +279,9 @@ gc_consumer_register(const struct vclock *vclock, const char *format, ...)
 void
 gc_consumer_unregister(struct gc_consumer *consumer)
 {
-	int64_t signature = vclock_sum(&consumer->vclock);
-
 	gc_tree_remove(&gc.consumers, consumer);
 	gc_consumer_delete(consumer);
-
-	/*
-	 * Rerun garbage collection after removing the consumer
-	 * if it referenced the oldest vclock.
-	 */
-	struct gc_consumer *leftmost = gc_tree_first(&gc.consumers);
-	if (leftmost == NULL || vclock_sum(&leftmost->vclock) > signature)
-		gc_run();
+	gc_run();
 }
 
 void
@@ -319,13 +310,7 @@ gc_consumer_advance(struct gc_consumer *consumer, const struct vclock *vclock)
 	if (update_tree)
 		gc_tree_insert(&gc.consumers, consumer);
 
-	/*
-	 * Rerun garbage collection after advancing the consumer
-	 * if it referenced the oldest vclock.
-	 */
-	struct gc_consumer *leftmost = gc_tree_first(&gc.consumers);
-	if (leftmost == NULL || vclock_sum(&leftmost->vclock) > prev_signature)
-		gc_run();
+	gc_run();
 }
 
 struct gc_consumer *
-- 
GitLab