summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Branca <chewbranca@apache.org>2020-09-17 16:14:18 -0700
committerRussell Branca <chewbranca@apache.org>2020-09-22 14:56:24 -0700
commit4a09cfa263f05f8825ef320c3a9e532a234ee5df (patch)
tree436f193a554d6a57beabd5b5688043d3e7654e8c
parentc2c282204978ecbf7034b8f89b7260f3a3e6116e (diff)
downloadcouchdb-3160-3.x-fix-run-queue-metric.tar.gz
Workaround dirty schedulers in run_queue stats3160-3.x-fix-run-queue-metric
-rw-r--r--src/chttpd/src/chttpd_node.erl17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/chttpd/src/chttpd_node.erl b/src/chttpd/src/chttpd_node.erl
index 033abd68d..6407df106 100644
--- a/src/chttpd/src/chttpd_node.erl
+++ b/src/chttpd/src/chttpd_node.erl
@@ -15,7 +15,8 @@
-export([
handle_node_req/1,
- get_stats/0
+ get_stats/0,
+ run_queues/0
]).
-include_lib("couch/include/couch_db.hrl").
@@ -210,10 +211,12 @@ get_stats() ->
{CF, CDU} = db_pid_stats(),
MessageQueues0 = [{couch_file, {CF}}, {couch_db_updater, {CDU}}],
MessageQueues = MessageQueues0 ++ message_queues(registered()),
+ {SQ, DCQ} = run_queues(),
[
{uptime, couch_app:uptime() div 1000},
{memory, {Memory}},
- {run_queue, statistics(run_queue)},
+ {run_queue, SQ},
+ {run_queue_dirty_cpu, DCQ},
{ets_table_count, length(ets:all())},
{context_switches, element(1, statistics(context_switches))},
{reductions, element(1, statistics(reductions))},
@@ -285,3 +288,13 @@ message_queues(Registered) ->
{Type, Length} = process_info(whereis(Name), Type),
{Name, Length}
end, Registered).
+
+%% Workaround for https://bugs.erlang.org/browse/ERL-1355
+run_queues() ->
+ case erlang:system_info(dirty_cpu_schedulers) > 0 of
+ false ->
+ {statistics(run_queue), 0};
+ true ->
+ [DCQ | SQs] = lists:reverse(statistics(run_queue_lengths)),
+ {lists:sum(SQs), DCQ}
+ end.