Skip to content

Commit 275c06b

Browse files
committed
Cleanup off-heap/priority flags
Make all processes run at normal priority. In production observed cases which had a very couch cfile cleaner queue (500k messages). That's likely because couch_servers are running at high priority on every scheduler, opening/closing files, and the single couch_cfile janitor process runs at normal priority, and can't keep up with cleanup. Since there is no super-high-priority to set the janitor to, let's just set them all to normal. Besides, we've had issue with high priority proceses before triggering various OTP bugs and had to revert at least once before: erlang/otp#4078. Also, in the same vein, we never had to disable the off_heap flag in 7 years since it's been made configurable, so let's remove the extra config fluff and always set it unconditionally.
1 parent 9bbef59 commit 275c06b

10 files changed

Lines changed: 8 additions & 50 deletions

File tree

rel/overlay/etc/default.ini

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,19 +1233,3 @@ url = {{nouveau_url}}
12331233
; from the _first_ authentication failure.
12341234
; note: changing this setting requires a couchdb restart.
12351235
;max_lifetime = 300000
1236-
1237-
[off_heap_mqd]
1238-
; Set Erlang process_flag(message_queue_data, off_heap) for the respective
1239-
; module if the setting is true. Off-heap messages do not participate in the
1240-
; process garbage collection. If processes expect to get a large message queue,
1241-
; it usually make sense to set to true, as otherwise GC may take too long.
1242-
; However in some cases that could affect latency as it takes an extra copy
1243-
; step to copy them into the process heap.
1244-
;rexi_server = true
1245-
;couch_log_server = true
1246-
;couch_server = true
1247-
;couch_event_server = true
1248-
;ddoc_cache_lru = true
1249-
;mem3_shards = true
1250-
;nouveau_index_manager = true
1251-
;dreyfus_index_manager = true

src/couch/src/couch_server.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ close_db_if_idle(DbName) ->
279279
end.
280280

281281
init([N]) ->
282-
couch_util:set_mqd_off_heap(?MODULE),
283-
couch_util:set_process_priority(?MODULE, high),
282+
erlang:process_flag(message_queue_data, off_heap),
284283

285284
% Mark pluggable storage engines as a supported feature
286285
config:enable_feature('pluggable-storage-engines'),

src/couch/src/couch_util.erl

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
-export([unique_monotonic_integer/0]).
4040
-export([check_config_blacklist/1]).
4141
-export([check_md5/2]).
42-
-export([set_mqd_off_heap/1]).
43-
-export([set_process_priority/2]).
4442
-export([hmac/3]).
4543
-export([version_to_binary/1]).
4644
-export([verify_hash_names/2]).
@@ -685,29 +683,6 @@ check_md5(_NewSig, <<>>) -> ok;
685683
check_md5(Sig, Sig) -> ok;
686684
check_md5(_, _) -> throw(md5_mismatch).
687685

688-
set_mqd_off_heap(Module) ->
689-
case config:get_boolean("off_heap_mqd", atom_to_list(Module), true) of
690-
true ->
691-
try
692-
erlang:process_flag(message_queue_data, off_heap),
693-
ok
694-
catch
695-
error:badarg ->
696-
ok
697-
end;
698-
false ->
699-
ok
700-
end.
701-
702-
set_process_priority(Module, Level) ->
703-
case config:get_boolean("process_priority", atom_to_list(Module), false) of
704-
true ->
705-
process_flag(priority, Level),
706-
ok;
707-
false ->
708-
ok
709-
end.
710-
711686
ensure_loaded(Module) when is_atom(Module) ->
712687
case code:ensure_loaded(Module) of
713688
{module, Module} ->

src/couch_event/src/couch_event_server.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ start_link() ->
3333
gen_server:start_link({local, ?MODULE}, ?MODULE, nil, []).
3434

3535
init(_) ->
36-
couch_util:set_mqd_off_heap(?MODULE),
36+
erlang:process_flag(message_queue_data, off_heap),
3737
{ok, #st{
3838
by_pid = #{},
3939
by_dbname = #{}

src/couch_log/src/couch_log_server.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ log(Entry) ->
4747
?SEND(Entry).
4848

4949
init(_) ->
50-
couch_util:set_mqd_off_heap(?MODULE),
50+
erlang:process_flag(message_queue_data, off_heap),
5151
process_flag(trap_exit, true),
5252
{ok, #st{
5353
writer = couch_log_writer:init()

src/ddoc_cache/src/ddoc_cache_lru.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ refresh(DbName, DDocIds) ->
7777
gen_server:cast(?MODULE, {refresh, DbName, DDocIds}).
7878

7979
init(_) ->
80-
couch_util:set_mqd_off_heap(?MODULE),
80+
erlang:process_flag(message_queue_data, off_heap),
8181
process_flag(trap_exit, true),
8282
BaseOpts = [public, named_table],
8383
CacheOpts =

src/dreyfus/src/dreyfus_index_manager.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ get_disk_size(DbName, #index{sig = Sig}) ->
4646
% gen_server functions.
4747

4848
init([]) ->
49-
couch_util:set_mqd_off_heap(?MODULE),
49+
erlang:process_flag(message_queue_data, off_heap),
5050
ets:new(?BY_SIG, [set, private, named_table]),
5151
ets:new(?BY_PID, [set, private, named_table]),
5252
couch_event:link_listener(?MODULE, handle_db_event, nil, [all_dbs]),

src/mem3/src/mem3_shards.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ handle_config_terminate(_Server, _Reason, _State) ->
230230
erlang:send_after(?RELISTEN_DELAY, whereis(?MODULE), restart_config_listener).
231231

232232
init([]) ->
233-
couch_util:set_mqd_off_heap(?MODULE),
233+
erlang:process_flag(message_queue_data, off_heap),
234234
CacheEtsOpts = [public, named_table, {read_concurrency, true}, {write_concurrency, auto}],
235235
ets:new(?OPTS, CacheEtsOpts),
236236
ets:new(?SHARDS, [bag, {keypos, #shard.dbname}] ++ CacheEtsOpts),

src/nouveau/src/nouveau_index_manager.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ update_index(#index{} = Index) ->
5353
end.
5454

5555
init(_) ->
56-
couch_util:set_mqd_off_heap(?MODULE),
56+
erlang:process_flag(message_queue_data, off_heap),
5757
ets:new(?BY_DBSIG, [set, named_table]),
5858
ets:new(?BY_REF, [set, named_table]),
5959
couch_event:link_listener(?MODULE, handle_db_event, nil, [all_dbs]),

src/rexi/src/rexi_server.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ start_link(ServerId) ->
4343
gen_server:start_link({local, ServerId}, ?MODULE, [], []).
4444

4545
init([]) ->
46-
couch_util:set_mqd_off_heap(?MODULE),
46+
erlang:process_flag(message_queue_data, off_heap),
4747
{ok, #st{}}.
4848

4949
handle_call(get_errors, _From, #st{errors = Errors} = St) ->

0 commit comments

Comments
 (0)