couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [couchdb] 01/05: feat: introduce snooze_period to reduce compaction_daemon load.
Date Mon, 05 Mar 2018 16:10:21 GMT
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch fix/compaction-daemon
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 827d8e8e8be7bc84192c7a13fd25ac10b6083b57
Author: Jan Lehnardt <jan@apache.org>
AuthorDate: Mon Mar 5 16:06:21 2018 +0100

    feat: introduce snooze_period to reduce compaction_daemon load.
    
    This commit introduces a snooze period for the compaction daemon
    to apply inbetween moving on from one database compaction to
    another, and from one view group to another.
    
    The result is that on db-per-user setups, the compaction daemon
    doesn’t cause a CPU spike every check_interval seconds.
---
 src/couch/src/couch_compaction_daemon.erl | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/couch/src/couch_compaction_daemon.erl b/src/couch/src/couch_compaction_daemon.erl
index 9371119..59555f1 100644
--- a/src/couch/src/couch_compaction_daemon.erl
+++ b/src/couch/src/couch_compaction_daemon.erl
@@ -126,6 +126,7 @@ handle_config_terminate(_Server, _Reason, _State) ->
     erlang:send_after(?RELISTEN_DELAY, whereis(?MODULE), restart_config_listener).
 
 compact_loop(Parent) ->
+    SnoozePeriod = config:get_integer("compaction_daemon", "snooze_period", 3),
     {ok, _} = couch_server:all_databases(
         fun(DbName, Acc) ->
             case ets:info(?CONFIG_ETS, size) =:= 0 of
@@ -138,7 +139,8 @@ compact_loop(Parent) ->
                 {ok, Config} ->
                     case check_period(Config) of
                     true ->
-                        maybe_compact_db(Parent, DbName, Config);
+                        maybe_compact_db(Parent, DbName, Config),
+                        ok = timer:sleep(SnoozePeriod * 1000);
                     false ->
                         ok
                     end
@@ -229,7 +231,9 @@ maybe_compact_views(DbName, [DDocName | Rest], Config) ->
             maybe_compact_views(DbName, Rest, Config);
         timeout ->
             ok
-        end;
+        end,
+        SnoozePeriod = config:get_integer("compaction_daemon", "snooze_period", 3),
+        ok = timer:sleep(SnoozePeriod * 1000);
     false ->
         ok
     end.

-- 
To stop receiving notification emails like this one, please contact
jan@apache.org.

Mime
View raw message