From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH v2 06/10] gc: some renames Date: Sat, 8 Dec 2018 18:48:10 +0300 [thread overview] Message-ID: <fa5e542f5d84bc0447ae5b486fe42ab124691887.1544282224.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1544282224.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1544282224.git.vdavydov.dev@gmail.com> GC module is responsible not only for garbage collection, but also for tracking consumers and making checkpoints. Soon it will also incorporate the checkpoint daemon. Let's prefix all members related to the cleanup procedure accordingly to avoid confusion. --- src/box/gc.c | 50 +++++++++++++++++++++++++------------------------- src/box/gc.h | 8 ++++---- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/box/gc.c b/src/box/gc.c index 153ef65c..e1b23eed 100644 --- a/src/box/gc.c +++ b/src/box/gc.c @@ -59,7 +59,7 @@ struct gc_state gc; static int -gc_fiber_f(va_list); +gc_cleanup_fiber_f(va_list); /** * Comparator used for ordering gc_consumer objects by signature @@ -107,13 +107,13 @@ gc_init(void) vclock_create(&gc.vclock); rlist_create(&gc.checkpoints); gc_tree_new(&gc.consumers); - fiber_cond_create(&gc.cond); + fiber_cond_create(&gc.cleanup_cond); - gc.fiber = fiber_new("gc", gc_fiber_f); - if (gc.fiber == NULL) + gc.cleanup_fiber = fiber_new("gc", gc_cleanup_fiber_f); + if (gc.cleanup_fiber == NULL) panic("failed to start garbage collection fiber"); - fiber_start(gc.fiber); + fiber_start(gc.cleanup_fiber); } void @@ -147,7 +147,7 @@ gc_free(void) * this function is specified by box.cfg.checkpoint_count. */ static void -gc_run(void) +gc_run_cleanup(void) { bool run_wal_gc = false; bool run_engine_gc = false; @@ -209,20 +209,20 @@ gc_run(void) } static int -gc_fiber_f(va_list ap) +gc_cleanup_fiber_f(va_list ap) { (void)ap; while (!fiber_is_cancelled()) { - int delta = gc.scheduled - gc.completed; + int delta = gc.cleanup_scheduled - gc.cleanup_completed; if (delta == 0) { /* No pending garbage collection. */ fiber_sleep(TIMEOUT_INFINITY); continue; } assert(delta > 0); - gc_run(); - gc.completed += delta; - fiber_cond_signal(&gc.cond); + gc_run_cleanup(); + gc.cleanup_completed += delta; + fiber_cond_signal(&gc.cleanup_cond); } return 0; } @@ -231,7 +231,7 @@ gc_fiber_f(va_list ap) * Trigger asynchronous garbage collection. */ static void -gc_schedule(void) +gc_schedule_cleanup(void) { /* * Do not wake up the background fiber if it's executing @@ -241,8 +241,8 @@ gc_schedule(void) * then - it will rerun garbage collection as soon as * the current round completes. */ - if (gc.scheduled++ == gc.completed) - fiber_wakeup(gc.fiber); + if (gc.cleanup_scheduled++ == gc.cleanup_completed) + fiber_wakeup(gc.cleanup_fiber); } /** @@ -250,11 +250,11 @@ gc_schedule(void) * to this point to complete. */ static void -gc_wait(void) +gc_wait_cleanup(void) { - unsigned scheduled = gc.scheduled; - while (gc.completed < scheduled) - fiber_cond_wait(&gc.cond); + unsigned scheduled = gc.cleanup_scheduled; + while (gc.cleanup_completed < scheduled) + fiber_cond_wait(&gc.cleanup_cond); } void @@ -284,7 +284,7 @@ gc_advance(const struct vclock *vclock) consumer = next; } - gc_schedule(); + gc_schedule_cleanup(); } void @@ -305,7 +305,7 @@ gc_add_checkpoint(const struct vclock *vclock) * Rerun the garbage collector in this case, just * in case box.cfg.checkpoint_count has changed. */ - gc_schedule(); + gc_schedule_cleanup(); return; } assert(last_checkpoint == NULL || @@ -324,7 +324,7 @@ gc_add_checkpoint(const struct vclock *vclock) rlist_add_tail_entry(&gc.checkpoints, checkpoint, in_checkpoints); gc.checkpoint_count++; - gc_schedule(); + gc_schedule_cleanup(); } int @@ -381,7 +381,7 @@ out: * files have been removed. */ if (rc == 0) - gc_wait(); + gc_wait_cleanup(); return rc; } @@ -402,7 +402,7 @@ void gc_unref_checkpoint(struct gc_checkpoint_ref *ref) { rlist_del_entry(ref, in_refs); - gc_schedule(); + gc_schedule_cleanup(); } struct gc_consumer * @@ -430,7 +430,7 @@ gc_consumer_unregister(struct gc_consumer *consumer) { if (!consumer->is_inactive) { gc_tree_remove(&gc.consumers, consumer); - gc_schedule(); + gc_schedule_cleanup(); } gc_consumer_delete(consumer); } @@ -464,7 +464,7 @@ gc_consumer_advance(struct gc_consumer *consumer, const struct vclock *vclock) if (update_tree) gc_tree_insert(&gc.consumers, consumer); - gc_schedule(); + gc_schedule_cleanup(); } struct gc_consumer * diff --git a/src/box/gc.h b/src/box/gc.h index 84a441f2..15927726 100644 --- a/src/box/gc.h +++ b/src/box/gc.h @@ -123,13 +123,13 @@ struct gc_state { /** Registered consumers, linked by gc_consumer::node. */ gc_tree_t consumers; /** Fiber that removes old files in the background. */ - struct fiber *fiber; + struct fiber *cleanup_fiber; /** - * Condition variable signaled by the background fiber + * Condition variable signaled by the cleanup fiber * whenever it completes a round of garbage collection. * Used to wait for garbage collection to complete. */ - struct fiber_cond cond; + struct fiber_cond cleanup_cond; /** * The following two members are used for scheduling * background garbage collection and waiting for it to @@ -141,7 +141,7 @@ struct gc_state { * sleep until @completed reaches the value of @scheduled * taken at that moment of time. */ - unsigned completed, scheduled; + unsigned cleanup_completed, cleanup_scheduled; /** * Set if there's a fiber making a checkpoint right now. */ -- 2.11.0
next prev parent reply other threads:[~2018-12-08 15:48 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-12-08 15:48 [PATCH v2 00/10] Allow to limit size of WAL files Vladimir Davydov 2018-12-08 15:48 ` [PATCH v2 01/10] gc: do not use WAL watcher API for deactivating stale consumers Vladimir Davydov 2018-12-08 21:41 ` Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 02/10] wal: simplify watcher API Vladimir Davydov 2018-12-08 21:41 ` Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 03/10] box: fix certain cfg options initialized twice on recovery Vladimir Davydov 2018-12-08 21:42 ` Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 04/10] box: don't use box_checkpoint_is_in_progress outside box.cc Vladimir Davydov 2018-12-08 21:43 ` Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 05/10] box: move checkpointing to gc module Vladimir Davydov 2018-12-08 21:44 ` Konstantin Osipov 2018-12-08 15:48 ` Vladimir Davydov [this message] 2018-12-08 21:44 ` [PATCH v2 06/10] gc: some renames Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 07/10] Introduce checkpoint schedule module Vladimir Davydov 2018-12-08 21:45 ` Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 08/10] Rewrite checkpoint daemon in C Vladimir Davydov 2018-12-08 21:45 ` Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 09/10] wal: pass struct instead of vclock to checkpoint methods Vladimir Davydov 2018-12-08 21:46 ` Konstantin Osipov 2018-12-08 15:48 ` [PATCH v2 10/10] wal: trigger checkpoint if there are too many WALs Vladimir Davydov 2018-12-08 21:48 ` Konstantin Osipov 2018-12-09 11:20 ` [PATCH v2 00/10] Allow to limit size of WAL files 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=fa5e542f5d84bc0447ae5b486fe42ab124691887.1544282224.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v2 06/10] gc: some renames' \ /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