From 6328a1345783d13684407fc6dcbe9ea473c12cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=B6m=C3=B6ri?= Date: Wed, 7 Feb 2018 09:20:11 +0100 Subject: Remove 'Example' without an example from docs --- lib/tools/doc/src/lcnt.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tools/doc/src/lcnt.xml b/lib/tools/doc/src/lcnt.xml index 5bdfc60448..0c24375b91 100644 --- a/lib/tools/doc/src/lcnt.xml +++ b/lib/tools/doc/src/lcnt.xml @@ -371,7 +371,7 @@ Serial = integer() -

Creates a process id with creation 0. Example:

+

Creates a process id with creation 0.

-- cgit v1.2.3 From ab965710d014912cbd3c4ef8f9c3acc0dffa1d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Fri, 9 Feb 2018 10:24:43 +0100 Subject: Automatically start lcnt server on first use lcnt:collect is documented as implicitly starting the lcnt server but didn't do so prior to this commit. I've decided to extend this behavior to all operations as the overhead is negligible and it's a bit more convenient to use. --- lib/tools/src/lcnt.erl | 7 ++++--- lib/tools/test/lcnt_SUITE.erl | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/tools/src/lcnt.erl b/lib/tools/src/lcnt.erl index 139b3d8a4a..20b031a7ad 100644 --- a/lib/tools/src/lcnt.erl +++ b/lib/tools/src/lcnt.erl @@ -218,9 +218,11 @@ raw() -> call(raw). set(Option, Value) -> call({set, Option, Value}). set({Option, Value}) -> call({set, Option, Value}). save(Filename) -> call({save, Filename}). -load(Filename) -> ok = start_internal(), call({load, Filename}). +load(Filename) -> call({load, Filename}). -call(Msg) -> gen_server:call(?MODULE, Msg, infinity). +call(Msg) -> + ok = start_internal(), + gen_server:call(?MODULE, Msg, infinity). %% -------------------------------------------------------------------- %% %% @@ -237,7 +239,6 @@ apply(Fun) when is_function(Fun) -> lcnt:apply(Fun, []). apply(Fun, As) when is_function(Fun) -> - ok = start_internal(), Opt = lcnt:rt_opt({copy_save, true}), lcnt:clear(), Res = erlang:apply(Fun, As), diff --git a/lib/tools/test/lcnt_SUITE.erl b/lib/tools/test/lcnt_SUITE.erl index 146c915087..4a92abb5c8 100644 --- a/lib/tools/test/lcnt_SUITE.erl +++ b/lib/tools/test/lcnt_SUITE.erl @@ -30,6 +30,7 @@ t_conflicts/1, t_locations/1, t_swap_keys/1, + t_implicit_start/1, smoke_lcnt/1]). init_per_testcase(_Case, Config) -> @@ -44,7 +45,7 @@ suite() -> {timetrap,{minutes,4}}]. all() -> - [t_load, t_conflicts, t_locations, t_swap_keys, + [t_load, t_conflicts, t_locations, t_swap_keys, t_implicit_start, smoke_lcnt]. %%---------------------------------------------------------------------- @@ -149,6 +150,11 @@ t_swap_keys_file([File|Files]) -> ok = lcnt:stop(), t_swap_keys_file(Files). +%% Prior to OTP-14913 this would crash with 'noproc' as the lcnt server hadn't +%% been started yet. +t_implicit_start(Config) when is_list(Config) -> + ok = lcnt:conflicts(). + %% Simple smoke test of actual lock-counting, if running on %% a run-time with lock-counting enabled. smoke_lcnt(Config) -> -- cgit v1.2.3 From dfa4d62c263cd3f11338aba891179b08704d9287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=B6m=C3=B6ri?= Date: Wed, 7 Feb 2018 09:20:11 +0100 Subject: Don't crash lcnt server if information/0 is called before collect/0 --- lib/tools/src/lcnt.erl | 2 +- lib/tools/test/lcnt_SUITE.erl | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/tools/src/lcnt.erl b/lib/tools/src/lcnt.erl index 139b3d8a4a..e306979dea 100644 --- a/lib/tools/src/lcnt.erl +++ b/lib/tools/src/lcnt.erl @@ -943,7 +943,7 @@ print_state_information(#state{locks = Locks} = State) -> print(kv("#tries", s(Stats#stats.tries))), print(kv("#colls", s(Stats#stats.colls))), print(kv("wait time", s(Stats#stats.time) ++ " us" ++ " ( " ++ s(Stats#stats.time/1000000) ++ " s)")), - print(kv("percent of duration", s(Stats#stats.time/State#state.duration*100) ++ " %")), + print(kv("percent of duration", s(percent(Stats#stats.time, State#state.duration)) ++ " %")), ok. diff --git a/lib/tools/test/lcnt_SUITE.erl b/lib/tools/test/lcnt_SUITE.erl index 146c915087..f0c36dedd9 100644 --- a/lib/tools/test/lcnt_SUITE.erl +++ b/lib/tools/test/lcnt_SUITE.erl @@ -30,6 +30,7 @@ t_conflicts/1, t_locations/1, t_swap_keys/1, + t_crash_before_collect/1, smoke_lcnt/1]). init_per_testcase(_Case, Config) -> @@ -44,7 +45,7 @@ suite() -> {timetrap,{minutes,4}}]. all() -> - [t_load, t_conflicts, t_locations, t_swap_keys, + [t_load, t_conflicts, t_locations, t_swap_keys, t_crash_before_collect, smoke_lcnt]. %%---------------------------------------------------------------------- @@ -149,6 +150,10 @@ t_swap_keys_file([File|Files]) -> ok = lcnt:stop(), t_swap_keys_file(Files). +t_crash_before_collect(Config) when is_list(Config) -> + {ok, _} = lcnt:start(), + ok = lcnt:information(). + %% Simple smoke test of actual lock-counting, if running on %% a run-time with lock-counting enabled. smoke_lcnt(Config) -> -- cgit v1.2.3