You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2024/09/02 23:48:42 UTC
(couchdb) branch couch-stats-resource-tracker-v2 updated (5864ba3c0 -> 4535f1a1f)
This is an automated email from the ASF dual-hosted git repository.
chewbranca pushed a change to branch couch-stats-resource-tracker-v2
in repository https://gitbox.apache.org/repos/asf/couchdb.git
from 5864ba3c0 Rework CSRT to use ets:fun2ms for static queries
new e1fead4e5 Remove debug statements
new 4535f1a1f Add find by nonce and some cleanup
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/couch_stats_resource_tracker.erl | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
(couchdb) 02/02: Add find by nonce and some cleanup
Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
chewbranca pushed a commit to branch couch-stats-resource-tracker-v2
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 4535f1a1fa1fc902781a744b105fd7c1147c5efe
Author: Russell Branca <ch...@apache.org>
AuthorDate: Mon Sep 2 16:44:40 2024 -0700
Add find by nonce and some cleanup
---
src/couch_stats/src/couch_stats_resource_tracker.erl | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/couch_stats/src/couch_stats_resource_tracker.erl b/src/couch_stats/src/couch_stats_resource_tracker.erl
index 98459d3ba..0594338bd 100644
--- a/src/couch_stats/src/couch_stats_resource_tracker.erl
+++ b/src/couch_stats/src/couch_stats_resource_tracker.erl
@@ -40,7 +40,7 @@
create_worker_context/3,
destroy_context/0, destroy_context/1,
- get_resource/0, get_resource/1, get_resource_raw/1,
+ get_resource/0, get_resource/1,
set_context_dbname/1, set_context_dbname/2,
set_context_handler_fun/1, set_context_handler_fun/2,
@@ -74,6 +74,7 @@
find_by_pid/1,
find_by_pidref/1,
+ find_by_nonce/1,
find_workers_by_pidref/1
]).
@@ -193,12 +194,7 @@ get_resource() ->
get_resource(undefined) ->
undefined;
get_resource(PidRef) ->
- catch get_resource_raw(PidRef).
-
-get_resource_raw(undefined) ->
- undefined;
-get_resource_raw(PidRef) ->
- case ets:lookup(?MODULE, PidRef) of
+ catch case ets:lookup(?MODULE, PidRef) of
[#rctx{}=Rctx] ->
Rctx;
[] ->
@@ -241,6 +237,9 @@ select_by_type(workers) ->
select_by_type(all) ->
ets:tab2list(?MODULE).
+find_by_nonce(Nonce) ->
+ ets:match_object(?MODULE, ets:fun2ms(fun(#rctx{nonce = Nonce1} = R) when Nonce =:= Nonce1 -> R end)).
+
find_by_pid(Pid) ->
[R || #rctx{} = R <- ets:match_object(?MODULE, #rctx{pid_ref={Pid, '_'}, _ = '_'})].
@@ -634,7 +633,7 @@ should_track(_Metric) ->
false.
ioq_called() ->
- is_enabled() andalso inc(ioq_calls).
+ inc(ioq_calls).
accumulate_delta(Delta) when is_map(Delta) ->
%% TODO: switch to creating a batch of updates to invoke a single
@@ -784,6 +783,7 @@ tracker({Pid, _Ref}=PidRef) ->
%% Reason0 ->
%% Reason0
%% end,
+ %% TODO: should we send the induced work delta to the coordinator?
log_process_lifetime_report(PidRef),
catch evict(PidRef)
end.
@@ -791,7 +791,7 @@ tracker({Pid, _Ref}=PidRef) ->
log_process_lifetime_report(PidRef) ->
case is_enabled() andalso is_logging_enabled() of
true ->
- Rctx = get_resource_raw(PidRef),
+ Rctx = get_resource(PidRef),
case should_log(Rctx) of
true ->
couch_log:report("csrt-pid-usage-lifetime", to_json(Rctx));
(couchdb) 01/02: Remove debug statements
Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
chewbranca pushed a commit to branch couch-stats-resource-tracker-v2
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e1fead4e54f608b3ab98978bd5caea6d2b23d4d4
Author: Russell Branca <ch...@apache.org>
AuthorDate: Wed Aug 28 11:19:07 2024 -0700
Remove debug statements
---
src/couch_stats/src/couch_stats_resource_tracker.erl | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/couch_stats/src/couch_stats_resource_tracker.erl b/src/couch_stats/src/couch_stats_resource_tracker.erl
index 3e3a75f37..98459d3ba 100644
--- a/src/couch_stats/src/couch_stats_resource_tracker.erl
+++ b/src/couch_stats/src/couch_stats_resource_tracker.erl
@@ -766,7 +766,6 @@ track(#rctx{pid_ref=PidRef}) ->
end.
tracker({Pid, _Ref}=PidRef) ->
- %%io:format("[~p]SPAWNED IN A TRACKER FOR ~p~n", [self(), PidRef]),
MonRef = erlang:monitor(process, Pid),
receive
stop ->
@@ -775,9 +774,8 @@ tracker({Pid, _Ref}=PidRef) ->
catch evict(PidRef),
demonitor(MonRef),
ok;
- {'DOWN', MonRef, _Type, _0DPid, Reason0} ->
+ {'DOWN', MonRef, _Type, _0DPid, _Reason0} ->
destroy_context(PidRef),
- io:format("[~p]SPAWNED IN A TRACKER FOR ~p:: GOT DOWN WITH {~p}~n", [self(), Pid, Reason0]),
%% TODO: should we pass reason to log_process_lifetime_report?
%% Reason = case Reason0 of
%% {shutdown, Shutdown0} ->