chiark / gitweb /
core: make GC more aggressive
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Jul 2013 15:41:57 +0000 (17:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Jul 2013 15:46:57 +0000 (17:46 +0200)
Since we should allow registering/unregistering transient units with the
same name in a tight-loop, we need to make the GC more aggressive, so
that dead units are cleaned up immediately instead of later.

hence, execute the GC sweep on every event loop iteration and clean up
units. This of course, means we need to be careful with adding units to
the GC queue, which we already are since we execute check_gc() of each
unit type already when adding something to the queue.

src/core/manager.c
src/core/manager.h
src/core/unit.c

index 080561b5d108a1729687c004fae4780daaaa01b8..612819442726341567174fd8f65fbe8f6fc4002c 100644 (file)
@@ -72,9 +72,6 @@
 #include "efivars.h"
 #include "env-util.h"
 
-/* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
-#define GC_QUEUE_ENTRIES_MAX 16
-
 /* As soon as 5s passed since a unit was added to our GC queue, make sure to run a gc sweep */
 #define GC_QUEUE_USEC_MAX (10*USEC_PER_SEC)
 
@@ -604,12 +601,7 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
 
         assert(m);
 
-        if ((m->n_in_gc_queue < GC_QUEUE_ENTRIES_MAX) &&
-            (m->gc_queue_timestamp <= 0 ||
-             (m->gc_queue_timestamp + GC_QUEUE_USEC_MAX) > now(CLOCK_MONOTONIC)))
-                return 0;
-
-        log_debug("Running GC...");
+        /* log_debug("Running GC..."); */
 
         m->gc_marker += _GC_OFFSET_MAX;
         if (m->gc_marker + _GC_OFFSET_MAX <= _GC_OFFSET_MAX)
@@ -636,7 +628,6 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
         }
 
         m->n_in_gc_queue = 0;
-        m->gc_queue_timestamp = 0;
 
         return n;
 }
@@ -1733,19 +1724,19 @@ int manager_loop(Manager *m) {
                 if (manager_dispatch_load_queue(m) > 0)
                         continue;
 
-                if (manager_dispatch_run_queue(m) > 0)
+                if (manager_dispatch_gc_queue(m) > 0)
                         continue;
 
-                if (bus_dispatch(m) > 0)
+                if (manager_dispatch_cleanup_queue(m) > 0)
                         continue;
 
-                if (manager_dispatch_cleanup_queue(m) > 0)
+                if (manager_dispatch_cgroup_queue(m) > 0)
                         continue;
 
-                if (manager_dispatch_gc_queue(m) > 0)
+                if (manager_dispatch_run_queue(m) > 0)
                         continue;
 
-                if (manager_dispatch_cgroup_queue(m) > 0)
+                if (bus_dispatch(m) > 0)
                         continue;
 
                 if (manager_dispatch_dbus_queue(m) > 0)
index 68cb2e4a3db224fd25591b6ae00d93ed36891b64..57a0a8d251ed2dd2081a4927a9dcceec1ed998c9 100644 (file)
@@ -206,7 +206,6 @@ struct Manager {
         CGroupControllerMask cgroup_supported;
         char *cgroup_root;
 
-        usec_t gc_queue_timestamp;
         int gc_marker;
         unsigned n_in_gc_queue;
 
index acc575b6e0adc1691d4bed568f745a8d18dc8183..447f2015ab5b50315272d806a6c86e6717c6608e 100644 (file)
@@ -311,9 +311,6 @@ void unit_add_to_gc_queue(Unit *u) {
         u->in_gc_queue = true;
 
         u->manager->n_in_gc_queue ++;
-
-        if (u->manager->gc_queue_timestamp <= 0)
-                u->manager->gc_queue_timestamp = now(CLOCK_MONOTONIC);
 }
 
 void unit_add_to_dbus_queue(Unit *u) {