From: Michal Karpinski Date: Thu, 13 Oct 2016 09:04:36 +0000 (+0100) Subject: DO NOT MERGE Fixing the netd benchmark X-Git-Tag: android-x86-7.1-r1~9 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d1da1b8a5e7d4d7de891af913c53b6f169a06f32;p=android-x86%2Fsystem-netd.git DO NOT MERGE Fixing the netd benchmark Bug: 29748723 (cherry picked from commit fe7f72b4709c2b735287d817b6f1277e2f40b11c) Change-Id: I3de12cab6d93a1ec928d47c7b3656eac99a91fb6 --- diff --git a/server/binder/android/net/metrics/INetdEventListener.aidl b/server/binder/android/net/metrics/INetdEventListener.aidl index 3d3774b..5a5ed8f 100644 --- a/server/binder/android/net/metrics/INetdEventListener.aidl +++ b/server/binder/android/net/metrics/INetdEventListener.aidl @@ -25,9 +25,9 @@ oneway interface INetdEventListener { const int EVENT_GETADDRINFO = 1; const int EVENT_GETHOSTBYNAME = 2; - const int REPORTING_LEVEL_NONE = 3; - const int REPORTING_LEVEL_METRICS = 4; - const int REPORTING_LEVEL_FULL = 5; + const int REPORTING_LEVEL_NONE = 0; + const int REPORTING_LEVEL_METRICS = 1; + const int REPORTING_LEVEL_FULL = 2; // Maximum number of IP addresses logged for DNS lookups before we truncate the full list. const int DNS_REPORTED_IP_ADDRESSES_LIMIT = 10; diff --git a/tests/benchmarks/Android.mk b/tests/benchmarks/Android.mk index c4f432b..438ce50 100644 --- a/tests/benchmarks/Android.mk +++ b/tests/benchmarks/Android.mk @@ -38,7 +38,8 @@ LOCAL_C_INCLUDES += system/netd/include \ LOCAL_SRC_FILES := main.cpp \ connect_benchmark.cpp \ - dns_benchmark.cpp + dns_benchmark.cpp \ + ../../server/binder/android/net/metrics/INetdEventListener.aidl LOCAL_MODULE_TAGS := eng tests diff --git a/tests/benchmarks/connect_benchmark.cpp b/tests/benchmarks/connect_benchmark.cpp index 56795d2..bcc643d 100644 --- a/tests/benchmarks/connect_benchmark.cpp +++ b/tests/benchmarks/connect_benchmark.cpp @@ -34,14 +34,10 @@ #include "FwmarkClient.h" #include "SockDiag.h" #include "Stopwatch.h" +#include "android/net/metrics/INetdEventListener.h" using android::base::StringPrintf; - -enum ReportingLevel { - NONE, - METRICS, - FULL -}; +using android::net::metrics::INetdEventListener; static int bindAndListen(int s) { sockaddr_in6 sin6 = { .sin6_family = AF_INET6 }; @@ -175,7 +171,7 @@ static void ipv6_loopback(benchmark::State& state, const bool waitBetweenRuns) { } static void run_at_reporting_level(decltype(ipv4_loopback) benchmarkFunction, - ::benchmark::State& state, const ReportingLevel reportingLevel, + ::benchmark::State& state, const int reportingLevel, const bool waitBetweenRuns) { // Our master thread (thread_index == 0) will control setup and teardown for other threads. const bool isMaster = (state.thread_index == 0); @@ -196,14 +192,14 @@ static void run_at_reporting_level(decltype(ipv4_loopback) benchmarkFunction, } } switch (reportingLevel) { - case NONE: + case INetdEventListener::REPORTING_LEVEL_NONE: setenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT, "", 1); break; - case METRICS: + case INetdEventListener::REPORTING_LEVEL_METRICS: unsetenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT); setenv(FwmarkClient::ANDROID_FWMARK_METRICS_ONLY, "", 1); break; - case FULL: + case INetdEventListener::REPORTING_LEVEL_FULL: unsetenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT); unsetenv(FwmarkClient::ANDROID_FWMARK_METRICS_ONLY); break; @@ -230,27 +226,28 @@ constexpr int MAX_THREADS = 1; constexpr double MIN_TIME = 0.5 /* seconds */; static void ipv4_metrics_reporting_no_fwmark(::benchmark::State& state) { - run_at_reporting_level(ipv4_loopback, state, NONE, true); + run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_NONE, true); } BENCHMARK(ipv4_metrics_reporting_no_fwmark)->MinTime(MIN_TIME)->UseManualTime(); // IPv4 metrics under low load static void ipv4_metrics_reporting_no_load(::benchmark::State& state) { - run_at_reporting_level(ipv4_loopback, state, METRICS, true); + run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, true); } BENCHMARK(ipv4_metrics_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); /* // TODO: uncomment once full reporting is available. static void ipv4_full_reporting_no_load(::benchmark::State& state) { - run_at_reporting_level(ipv4_loopback, state, FULL, true); + run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, true); } BENCHMARK(ipv4_full_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); */ // IPv4 benchmarks under high load static void ipv4_metrics_reporting_high_load(::benchmark::State& state) { - run_at_reporting_level(ipv4_loopback, state, METRICS, false); + run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, + false); } BENCHMARK(ipv4_metrics_reporting_high_load) ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); @@ -258,7 +255,7 @@ BENCHMARK(ipv4_metrics_reporting_high_load) /* // TODO: uncomment once full reporting is available. static void ipv4_full_reporting_high_load(::benchmark::State& state) { - run_at_reporting_level(ipv4_loopback, state, FULL, false); + run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, false); } BENCHMARK(ipv4_full_reporting_high_load) ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); @@ -266,27 +263,28 @@ BENCHMARK(ipv4_full_reporting_high_load) // IPv6 raw connect() without using fwmark static void ipv6_metrics_reporting_no_fwmark(::benchmark::State& state) { - run_at_reporting_level(ipv6_loopback, state, NONE, true); + run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_NONE, true); } BENCHMARK(ipv6_metrics_reporting_no_fwmark)->MinTime(MIN_TIME)->UseManualTime(); // IPv6 metrics under low load static void ipv6_metrics_reporting_no_load(::benchmark::State& state) { - run_at_reporting_level(ipv6_loopback, state, METRICS, true); + run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, true); } BENCHMARK(ipv6_metrics_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); /* // TODO: uncomment once full reporting is available. static void ipv6_full_reporting_no_load(::benchmark::State& state) { - run_at_reporting_level(ipv6_loopback, state, FULL, true); + run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, true); } BENCHMARK(ipv6_full_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); */ // IPv6 benchmarks under high load static void ipv6_metrics_reporting_high_load(::benchmark::State& state) { - run_at_reporting_level(ipv6_loopback, state, METRICS, false); + run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, + false); } BENCHMARK(ipv6_metrics_reporting_high_load) ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); @@ -294,7 +292,7 @@ BENCHMARK(ipv6_metrics_reporting_high_load) /* // TODO: uncomment once full reporting is available. static void ipv6_full_reporting_high_load(::benchmark::State& state) { - run_at_reporting_level(ipv6_loopback, state, FULL, false); + run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, false); } BENCHMARK(ipv6_full_reporting_high_load) ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); diff --git a/tests/benchmarks/dns_benchmark.cpp b/tests/benchmarks/dns_benchmark.cpp index 4307861..7cfd5a5 100644 --- a/tests/benchmarks/dns_benchmark.cpp +++ b/tests/benchmarks/dns_benchmark.cpp @@ -28,8 +28,10 @@ #include "dns_responder_client.h" #include "NetdClient.h" +#include "android/net/metrics/INetdEventListener.h" using android::base::StringPrintf; +using android::net::metrics::INetdEventListener; constexpr int MIN_THREADS = 1; constexpr int MAX_THREADS = 32; @@ -126,7 +128,7 @@ public: // DNS calls without any metrics logged or sent. BENCHMARK_DEFINE_F(DnsFixture, getaddrinfo_log_nothing)(benchmark::State& state) { - benchmark_at_reporting_level(state, 0); + benchmark_at_reporting_level(state, INetdEventListener::REPORTING_LEVEL_NONE); } BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_nothing) ->ThreadRange(MIN_THREADS, MAX_THREADS) @@ -134,7 +136,7 @@ BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_nothing) // DNS calls with metrics only (netId, latency, return code) sent to the system server. BENCHMARK_DEFINE_F(DnsFixture, getaddrinfo_log_metrics)(benchmark::State& state) { - benchmark_at_reporting_level(state, 1); + benchmark_at_reporting_level(state, INetdEventListener::REPORTING_LEVEL_METRICS); } BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_metrics) ->ThreadRange(MIN_THREADS, MAX_THREADS) @@ -142,7 +144,7 @@ BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_metrics) // DNS calls with all information logged and sent to the system server. BENCHMARK_DEFINE_F(DnsFixture, getaddrinfo_log_everything)(benchmark::State& state) { - benchmark_at_reporting_level(state, 2); + benchmark_at_reporting_level(state, INetdEventListener::REPORTING_LEVEL_FULL); } BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_everything) ->ThreadRange(MIN_THREADS, MAX_THREADS)