From 9f0e2acbdc7105f02a8cac2aa11cf9259dca34ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Thu, 18 May 2017 23:05:02 +0200 Subject: Make lock counter info independent of the locks being counted This allows us to enable/disable lock counting at will, and greatly improves the performance of erts_debug:lock_counters/1 since we no longer have to worry about the lock counters "dying" while we're enumerating them. OTP-14412 --- lib/tools/doc/src/lcnt.xml | 8 -------- 1 file changed, 8 deletions(-) (limited to 'lib/tools/doc') diff --git a/lib/tools/doc/src/lcnt.xml b/lib/tools/doc/src/lcnt.xml index 6e66a957ab..590049e681 100644 --- a/lib/tools/doc/src/lcnt.xml +++ b/lib/tools/doc/src/lcnt.xml @@ -109,14 +109,6 @@ statistics. If the server held any lock statistics data before the collect then that data is lost.

- -

- When collection occurs the runtime system transitions to a single thread, - blocking all other threads. No other tasks will be scheduled during this - operation. Depending on the size of the data this might take a long time - (several seconds) and cause timeouts in the system. -

-
-- cgit v1.2.3 From 876ecc058d0d7dd48f8c5f7ddaf189d278e69925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Thu, 29 Jun 2017 19:32:41 +0200 Subject: Document rt_mask and add warnings about copy_save --- lib/tools/doc/src/lcnt.xml | 98 +++++++++++++++++++++++++++++++++----- lib/tools/doc/src/lcnt_chapter.xml | 11 +++-- 2 files changed, 94 insertions(+), 15 deletions(-) (limited to 'lib/tools/doc') diff --git a/lib/tools/doc/src/lcnt.xml b/lib/tools/doc/src/lcnt.xml index 590049e681..922c2ac0f4 100644 --- a/lib/tools/doc/src/lcnt.xml +++ b/lib/tools/doc/src/lcnt.xml @@ -5,7 +5,7 @@
2009 - 2016 + 2017 Ericsson AB, All Rights Reserved @@ -314,24 +314,22 @@ apply(Fun) -> term() Same as apply(Fun, []). + + Fun = fun() +

Same as apply(Fun, []).

apply(Fun, Args) -> term() - Clears counters, applies function and collects the profiling results. + Same as apply(Module, Function, Args). Fun = fun() Args = [term()] -

Clears the lock counters and then setups the instrumentation to save all destroyed locks. - After setup the fun is called, passing the elements in Args as arguments. - When the fun returns the statistics are immediately collected to the server. After the - collection the instrumentation is returned to its previous behavior. - The result of the applied fun is returned. -

+

Same as apply(Module, Function, Args).

@@ -349,6 +347,13 @@ collection the instrumentation is returned to its previous behavior. The result of the applied function is returned.

+ +

+ This function should only be used for micro-benchmarks; it sets copy_save + to true for the duration of the call, which can quickly lead to running + out of memory. +

+
@@ -421,6 +426,68 @@

Clear the internal counters. Same as lcnt:clear(Node).

+ + rt_mask() -> [category_atom()] + Same as rt_mask(node()). +

Same as rt_mask(node()).

+
+ + + rt_mask(Node) -> [category_atom()] + Returns the current lock category mask. + + Node = node() + + +

+ Refer to rt_mask/2 for a list of valid categories. All + categories are enabled by default. +

+
+
+ + + rt_mask(Categories) -> ok | {error, copy_save_enabled} + Same as rt_mask(node(), Categories). + + Categories = [atom()] + +

Same as rt_mask(node(), Categories).

+
+ + + rt_mask(Node, Categories) -> ok | {error, copy_save_enabled} + Changes the lock category mask. + + Node = node() + Categories = [atom()] + + +

+ Sets the lock category mask to the given categories. +

+

+ This will fail if the copy_save option is enabled; see + lcnt:rt_opt/2. +

+

Valid categories are:

+ + allocator + db (ETS tables) + debug + distribution + generic + io + process + scheduler + +

+ This list is subject to change at any time, as is the category any given lock + may belong to. +

+
+
+ rt_opt({Type, bool()}) -> bool() Same as rt_opt(node(), {Type, Opt}). @@ -434,16 +501,25 @@ Type = copy_save | process_locks -

Changes the lock counter behavior and returns the previous behaviour.

Option description:

{copy_save, bool()} - Enable statistics saving from destroyed locks by copying. This might consume a lot of memory. + Retains the statistics of destroyed locks.
Default: false + +

+ This option will use a lot of memory when enabled, which must be + reclaimed with lcnt:rt_clear. Note that it makes no distinction + between locks that were destroyed and locks for which counting was + disabled, so enabling this option will disable changes to the lock + category mask. +

+
{process_locks, bool()} - Profile process locks. + Profile process locks, equal to adding process to the lock category mask; + see lcnt:rt_mask/2
Default: true
diff --git a/lib/tools/doc/src/lcnt_chapter.xml b/lib/tools/doc/src/lcnt_chapter.xml index 1981d66117..24b58136aa 100644 --- a/lib/tools/doc/src/lcnt_chapter.xml +++ b/lib/tools/doc/src/lcnt_chapter.xml @@ -4,7 +4,7 @@
- 20092016 + 20092017 Ericsson AB. All Rights Reserved. @@ -29,7 +29,7 @@ nobody no 2009-11-26 - PA1 + PA2 lcnt_chapter.xml

@@ -97,8 +97,11 @@ ok ok

- Another way to to profile a specific function is to use lcnt:apply/3 or lcnt:apply/1 which does lcnt:clear/0 before the function and lcnt:collect/0 after its invocation. - It also sets copy_save to true for the duration of the function call + Another way to to profile a specific function is to use lcnt:apply/3 or lcnt:apply/1 + which does lcnt:clear/0 before the function and lcnt:collect/0 after its invocation. + This method should only be used in micro-benchmarks since it sets copy_save to true + for the duration of the function call, which may cause the emulator to run out of memory if + attempted under load.

 Erlang R13B03 (erts-5.7.4) [source] [smp:8:8] [rq:8] [async-threads:0] [hipe]
-- 
cgit v1.2.3