You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "pgj (via GitHub)" <gi...@apache.org> on 2023/12/03 14:00:32 UTC
Re: [PR] PoC Couch Stats Resource Tracker for tracking process local resource usage [couchdb]
pgj commented on code in PR #4812:
URL: https://github.com/apache/couchdb/pull/4812#discussion_r1413085196
##########
src/rexi/src/rexi.erl:
##########
@@ -328,3 +336,23 @@ drain_acks(Count) ->
after 0 ->
{ok, Count}
end.
+
+get_delta() ->
+ {delta, couch_stats_resource_tracker:make_delta()}.
+
+maybe_add_delta(T) ->
+ case couch_stats_resource_tracker:is_enabled() of
+ false ->
+ T;
+ true ->
+ add_delta(T, get_delta())
+ end.
+
+add_delta({A}, Delta) -> {A, Delta};
Review Comment:
The same could be expressed with the help of `erlang:insert_element/3` and `erlang:size/1`:
```erlang
add_delta(T, Delta) -> erlang:insert_element(erlang:size(T) + 1, T, Delta).
```
If maximum tuple size matters (semantically equivalent):
```erlang
add_delta(T, Delta) when 0 < erlang:size(T), erlang:size(T) < 8 ->
erlang:insert_element(erlang:size(T) + 1, T, Delta);
add_delta(T, _Delta) -> T.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org