From fb821d422c6fc187f2a23805c559bdc9105eeb59 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 22 Oct 2018 16:52:00 +0200 Subject: ssl: Add some benchmarks to test The ssl benchmarks tend to break when doing other changes in ssl, so we add some of the benchmarks to be run as part of normal testing. --- lib/ssl/test/ssl.spec | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/ssl/test/ssl.spec b/lib/ssl/test/ssl.spec index cb54168d36..5e65bfcfe6 100644 --- a/lib/ssl/test/ssl.spec +++ b/lib/ssl/test/ssl.spec @@ -1,4 +1,9 @@ -{suites,"../ssl_test",all}. -{skip_suites, "../ssl_test", - [ssl_bench_SUITE, ssl_dist_bench_SUITE], - "Benchmarks run separately"}. +% {merge_tests,false}. +{alias,dir,"../ssl_test"}. + +{suites,dir,all}. +{skip_groups,dir,ssl_bench_SUITE,setup,"Benchmarks run separately"}. +{skip_groups,dir,ssl_bench_SUITE,pem_cache,"Benchmarks run separately"}. +{skip_groups,dir,ssl_dist_bench_SUITE,setup,"Benchmarks run separately"}. +{skip_groups,dir,ssl_dist_bench_SUITE,throughput,"Benchmarks run separately"}. + -- cgit v1.2.3 From c114cfdbc7cac327bd132b4eeada097a0cd7a5df Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 22 Oct 2018 16:54:28 +0200 Subject: ssl: Link to tstsrvr to group_leader in test If the check_ssl_node_up call is made by an rpc:call the calling process will terminate and thus the tstsrvr loop would terminate too early. We instead link with the group leader so that the look still terminates, but only if the parent node does. --- lib/ssl/test/ssl_dist_test_lib.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ssl/test/ssl_dist_test_lib.erl b/lib/ssl/test/ssl_dist_test_lib.erl index 1b9c853fc4..1511906654 100644 --- a/lib/ssl/test/ssl_dist_test_lib.erl +++ b/lib/ssl/test/ssl_dist_test_lib.erl @@ -179,8 +179,9 @@ check_ssl_node_up(Socket, Name, Bin) -> Parent = self(), Go = make_ref(), %% Spawn connection handler on test server side - Pid = spawn_link( + Pid = spawn( fun () -> + link(group_leader()), receive Go -> ok end, process_flag(trap_exit, true), tstsrvr_con_loop(Name, Socket, Parent) -- cgit v1.2.3 From 7fde3f1d86bd0a5536e9168a45d4802a568f03e1 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 23 Oct 2018 09:13:50 +0200 Subject: ssl: Add scheduler utilization benchmark of plain/tls dist --- lib/ssl/test/ssl_dist_bench_SUITE.erl | 98 ++++++++++++++++++++++++++++++++++- lib/ssl/test/ssl_dist_test_lib.erl | 2 + 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/lib/ssl/test/ssl_dist_bench_SUITE.erl b/lib/ssl/test/ssl_dist_bench_SUITE.erl index 3c7904cf24..daedd254d7 100644 --- a/lib/ssl/test/ssl_dist_bench_SUITE.erl +++ b/lib/ssl/test/ssl_dist_bench_SUITE.erl @@ -32,6 +32,7 @@ -export( [setup/1, roundtrip/1, + sched_utilization/1, throughput_1024/1, throughput_4096/1, throughput_16384/1, @@ -54,6 +55,7 @@ groups() -> %% {setup, [{repeat, 1}], [setup]}, {roundtrip, [{repeat, 1}], [roundtrip]}, + {sched_utilization,[{repeat, 1}], [sched_utilization]}, {throughput, [{repeat, 1}], [throughput_1024, throughput_4096, @@ -65,7 +67,9 @@ groups() -> all_groups() -> [{group, setup}, {group, roundtrip}, - {group, throughput}]. + {group, throughput}, + {group, sched_utilization} + ]. init_per_suite(Config) -> Digest = sha1, @@ -330,6 +334,98 @@ roundtrip_client(Pid, Mon, StartTime, N) -> roundtrip_client(Pid, Mon, StartTime, N - 1) end. +%%--------------------------------------- +%% Scheduler utilization at constant load + + +sched_utilization(Config) -> + run_nodepair_test( + fun(A, B, Prefix, HA, HB) -> + sched_utilization(A, B, Prefix, HA, HB, proplists:get_value(ssl_dist, Config)) + end, Config). + +sched_utilization(A, B, Prefix, HA, HB, SSL) -> + [] = ssl_apply(HA, erlang, nodes, []), + [] = ssl_apply(HB, erlang, nodes, []), + {ClientMsacc, ServerMsacc, Msgs} = + ssl_apply(HA, fun () -> sched_util_runner(A, B, SSL) end), + [B] = ssl_apply(HA, erlang, nodes, []), + [A] = ssl_apply(HB, erlang, nodes, []), + msacc:print(ClientMsacc), + msacc:print(ServerMsacc), + ct:pal("Got ~p msgs",[length(Msgs)]), + report(Prefix++" Sched Utilization Client", + 10000 * msacc:stats(system_runtime,ClientMsacc) / + msacc:stats(system_realtime,ClientMsacc), "util 0.01 %"), + report(Prefix++" Sched Utilization Server", + 10000 * msacc:stats(system_runtime,ServerMsacc) / + msacc:stats(system_realtime,ServerMsacc), "util 0.01 %"), + ok. + +%% Runs on node A and spawns a server on node B +%% We want to avoid getting busy_dist_port as it hides the true SU usage +%% of the receiver and sender. +sched_util_runner(A, B, true) -> + sched_util_runner(A, B, 50); +sched_util_runner(A, B, false) -> + sched_util_runner(A, B, 250); +sched_util_runner(A, B, Senders) -> + Payload = payload(5), + [A] = rpc:call(B, erlang, nodes, []), + ServerPid = + erlang:spawn( + B, + fun () -> throughput_server() end), + ServerMsacc = + erlang:spawn( + B, + fun() -> + receive + {start,Pid} -> + msacc:start(10000), + Pid ! {ServerPid,msacc:stats()} + end + end), + ServerMon = erlang:monitor(process, ServerPid), + ClientPid = + spawn_link(fun() -> + %% We spawn 250 senders which should mean that we + %% have a load of 250 msgs/msec + [spawn_link(fun() -> throughput_client(ServerPid,Payload) end) || + _ <- lists:seq(1, Senders)] + end), + + erlang:system_monitor(self(),[busy_dist_port]), + ServerMsacc ! {start,self()}, + msacc:start(10000), + ClientMsaccStats = msacc:stats(), + ServerMsaccStats = receive {ServerPid,Stats} -> Stats end, + {ClientMsaccStats,ServerMsaccStats, flush()}. + +flush() -> + receive + M -> + [M | flush()] + after 0 -> + [] + end. + +throughput_server() -> + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + receive _ -> ok end, + throughput_server(). + +throughput_client(Pid, Payload) -> + Pid ! Payload, + receive after 1 -> throughput_client(Pid, Payload) end. %%----------------- %% Throughput speed diff --git a/lib/ssl/test/ssl_dist_test_lib.erl b/lib/ssl/test/ssl_dist_test_lib.erl index 1511906654..b8b805b2c4 100644 --- a/lib/ssl/test/ssl_dist_test_lib.erl +++ b/lib/ssl/test/ssl_dist_test_lib.erl @@ -144,6 +144,8 @@ mk_node_cmdline(ListenPort, Name, Args) -> ++ integer_to_list(ListenPort) ++ " " ++ Args ++ " " ++ "-env ERL_CRASH_DUMP " ++ Pwd ++ "/erl_crash_dump." ++ Name ++ " " + ++ "-kernel inet_dist_connect_options \"[{recbuf,12582912},{sndbuf,12582912},{high_watermark,8388608},{low_watermark,4194304}]\" " + ++ "-kernel inet_dist_listen_options \"[{recbuf,12582912},{sndbuf,12582912},{high_watermark,8388608},{low_watermark,4194304}]\" " ++ "-kernel error_logger \"{file,\\\"" ++ Pwd ++ "/error_log." ++ Name ++ "\\\"}\" " ++ "-setcookie " ++ atom_to_list(erlang:get_cookie()). -- cgit v1.2.3 From 9694c72cae70fec65e19c8439a85d91cf21b39bf Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 23 Oct 2018 15:10:54 +0200 Subject: stdlib: Adjust binary bench to be faster When benchmarking releases before OTP-22 the binary:match function is very slow so it takes a long time to run the benchmarks. This commit makes the benchmark run for a shorter time which will make the results a bit less stable, but it will cut 1 hour from the benchmark regression so we will have to live with that. --- lib/stdlib/test/stdlib_bench_SUITE.erl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/stdlib/test/stdlib_bench_SUITE.erl b/lib/stdlib/test/stdlib_bench_SUITE.erl index b937eeb06a..436aa78a0f 100644 --- a/lib/stdlib/test/stdlib_bench_SUITE.erl +++ b/lib/stdlib/test/stdlib_bench_SUITE.erl @@ -38,7 +38,9 @@ groups() -> [norm_nfc_list, norm_nfc_deep_l, norm_nfc_binary, string_lexemes_list, string_lexemes_binary ]}, - {binary, [{repeat, 5}], + %% Only run 1 binary match repeat as it is very slow pre OTP-22. + %% The results seem to be stable enough anyway + {binary, [{repeat, 1}], [match_single_pattern_no_match, matches_single_pattern_no_match, matches_single_pattern_eventual_match, @@ -164,19 +166,19 @@ norm_data(Config) -> match_single_pattern_no_match(_Config) -> Binary = binary:copy(<<"ugbcfuysabfuqyfikgfsdalpaskfhgjsdgfjwsalp">>, 1000000), - comment(test(binary, match, [Binary, <<"o">>])). + comment(test(100, binary, match, [Binary, <<"o">>])). matches_single_pattern_no_match(_Config) -> Binary = binary:copy(<<"ugbcfuysabfuqyfikgfsdalpaskfhgjsdgfjwsalp">>, 1000000), - comment(test(binary, matches, [Binary, <<"o">>])). + comment(test(100, binary, matches, [Binary, <<"o">>])). matches_single_pattern_eventual_match(_Config) -> Binary = binary:copy(<<"ugbcfuysabfuqyfikgfsdalpaskfhgjsdgfjwsal\n">>, 1000000), - comment(test(binary, matches, [Binary, <<"\n">>])). + comment(test(100, binary, matches, [Binary, <<"\n">>])). matches_single_pattern_frequent_match(_Config) -> Binary = binary:copy(<<"abc\n">>, 1000000), - comment(test(binary, matches, [Binary, <<"abc">>])). + comment(test(100, binary, matches, [Binary, <<"abc">>])). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -233,9 +235,11 @@ list() -> random_byte_list(?SIZE). test(Mod, Fun, Args) -> - F = fun() -> loop(?N, Mod, Fun, Args) end, + test(?N, Mod, Fun, Args). +test(Iter, Mod, Fun, Args) -> + F = fun() -> loop(Iter, Mod, Fun, Args) end, {Time, ok} = timer:tc(fun() -> lspawn(F) end), - report_mfa(Time, Mod). + report_mfa(Iter, Time, Mod). loop(0, _M, _F, _A) -> garbage_collect(), ok; loop(N, M, F, A) -> @@ -248,8 +252,8 @@ lspawn(Fun) -> {'DOWN', Ref, process, Pid, Rep} -> Rep end. -report_mfa(Time, Mod) -> - Tps = round((?N*1000000)/Time), +report_mfa(Iter, Time, Mod) -> + Tps = round((Iter*1000000)/Time), ct_event:notify(#event{name = benchmark_data, data = [{suite, "stdlib_" ++ atom_to_list(Mod)}, {value, Tps}]}), -- cgit v1.2.3