From 5813fc6023f04f70668ce23e3963e3f6a49b00f1 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Tue, 13 Feb 2018 18:56:27 +0000 Subject: [PATCH] [github36] Another bunch of changes after review: - using namespace cleaned up - all host benchmarks are now commented - common parameters moved to parameters.h - code wrapping fixed --- src/lib/dhcpsrv/benchmarks/Makefile.am | 1 + .../cql_host_data_source_benchmark.cc | 87 +++++++++---- .../benchmarks/cql_lease_mgr_benchmark.cc | 1 + .../generic_host_data_source_benchmark.cc | 39 +++--- .../generic_host_data_source_benchmark.h | 18 ++- .../benchmarks/generic_lease_mgr_benchmark.h | 17 --- .../benchmarks/memfile_lease_mgr_benchmark.cc | 3 +- .../mysql_host_data_source_benchmark.cc | 117 ++++++++++++++---- .../benchmarks/mysql_lease_mgr_benchmark.cc | 4 +- src/lib/dhcpsrv/benchmarks/parameters.h | 43 +++++++ .../pgsql_host_data_source_benchmark.cc | 88 +++++++++---- .../benchmarks/pgsql_lease_mgr_benchmark.cc | 11 +- 12 files changed, 304 insertions(+), 125 deletions(-) create mode 100644 src/lib/dhcpsrv/benchmarks/parameters.h diff --git a/src/lib/dhcpsrv/benchmarks/Makefile.am b/src/lib/dhcpsrv/benchmarks/Makefile.am index 005452e231..7f2f05c6cb 100644 --- a/src/lib/dhcpsrv/benchmarks/Makefile.am +++ b/src/lib/dhcpsrv/benchmarks/Makefile.am @@ -23,6 +23,7 @@ run_benchmarks_SOURCES = run_benchmarks.cc run_benchmarks_SOURCES += generic_lease_mgr_benchmark.cc generic_lease_mgr_benchmark.h run_benchmarks_SOURCES += generic_host_data_source_benchmark.cc generic_host_data_source_benchmark.h run_benchmarks_SOURCES += memfile_lease_mgr_benchmark.cc +run_benchmarks_SOURCES += parameters.h if HAVE_MYSQL run_benchmarks_SOURCES += mysql_lease_mgr_benchmark.cc diff --git a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc index 6973a86e26..ad3dd6286a 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc @@ -18,18 +18,16 @@ #include #include +#include #include #include #include -using isc::dhcp::bench::GenericHostDataSourceBenchmark; -using isc::dhcp::test::createCqlSchema; -using isc::dhcp::test::destroyCqlSchema; -using isc::dhcp::HostDataSourceFactory; -using isc::dhcp::test::validCqlConnectionString; -using std::cerr; -using std::endl; +using namespace isc::dhcp::bench; +using namespace isc::dhcp::test; +using namespace isc::dhcp; +using namespace std; namespace { @@ -164,21 +162,64 @@ BENCHMARK_DEFINE_F(CqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& sta } } -constexpr size_t MIN_HOST_COUNT = 512; -constexpr size_t MAX_HOST_COUNT = 0xfffd; -constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond; - -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, insertHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, updateHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllByHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAll)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllv4Resv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6Prefix)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); +/// Defines parameters necessary for running a benchmark that measures +/// hosts insertion. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, insertHosts) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts update. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, updateHosts) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll(hw-addr, duid) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllByHWAddrDuid) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll4(hw-addr, duid) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAll) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll(v4-reservation) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, getAllv4Resv) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(subnet-id, hw-addr, duid) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4IdentifierSubnetId) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(subnet-id, v4-reservation) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get4SubnetIdv4Resrv) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, duid, hw-addr) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6IdentifierSubnetId) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, ip-address) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6SubnetIdAddr) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(ip-prefix, prefix-len) call. +BENCHMARK_REGISTER_F(CqlHostDataSourceBenchmark, get6Prefix) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); } // namespace diff --git a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc index eed7ed0583..5f21cd8591 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include diff --git a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc index 83d2676230..ed944b0871 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc @@ -130,32 +130,22 @@ GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host, const bool f // Add DHCPv6 options. CfgOptionPtr opts = host->getCfgOption6(); opts->add(createOption(Option::V6, D6O_BOOTFILE_URL, true, - formatted, "my-boot-file"), - DHCP6_OPTION_SPACE); - opts->add(createOption(Option::V6, - D6O_INFORMATION_REFRESH_TIME, - false, formatted, 3600), - DHCP6_OPTION_SPACE); - opts->add(createVendorOption(Option::V6, false, formatted, 2495), - DHCP6_OPTION_SPACE); - opts->add(createAddressOption(1024, false, formatted, - "2001:db8:1::1"), + formatted, "my-boot-file"), DHCP6_OPTION_SPACE); + opts->add(createOption(Option::V6, D6O_INFORMATION_REFRESH_TIME, + false, formatted, 3600), DHCP6_OPTION_SPACE); + opts->add(createVendorOption(Option::V6, false, formatted, 2495), DHCP6_OPTION_SPACE); + opts->add(createAddressOption(1024, false, formatted, "2001:db8:1::1"), DHCP6_OPTION_SPACE); opts->add(createEmptyOption(Option::V6, 1, true), "isc2"); - opts->add(createAddressOption( - 2, false, formatted, "3000::1", "3000::2", "3000::3"), - "isc2"); + opts->add(createAddressOption(2, false, formatted, "3000::1", "3000::2", + "3000::3"), "isc2"); // Add definitions for DHCPv6 non-standard options. - defs.addItem(OptionDefinitionPtr(new OptionDefinition( - "option-1024", 1024, "ipv6-address", true)), - DHCP6_OPTION_SPACE); - defs.addItem( - OptionDefinitionPtr(new OptionDefinition("option-1", 1, "empty")), - "isc2"); - defs.addItem(OptionDefinitionPtr(new OptionDefinition( - "option-2", 2, "ipv6-address", true)), - "isc2"); + defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1024", 1024, "ipv6-address", + true)), DHCP6_OPTION_SPACE); + defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1", 1, "empty")), "isc2"); + defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2, "ipv6-address", + true)), "isc2"); } // Register created "runtime" option definitions. They will be used by a @@ -226,9 +216,8 @@ void GenericHostDataSourceBenchmark::benchGet4BySubnetHWAddrDuid() { for (HostPtr host : hosts_) { std::vector hwaddr = host->getIdentifier(); - hdsptr_->get4(host->getIPv4SubnetID(), - HWAddrPtr(new HWAddr(hwaddr, host->getIdentifierType())), - host->getDuid()); + hdsptr_->get4(host->getIPv4SubnetID(), HWAddrPtr(new HWAddr(hwaddr, + host->getIdentifierType())), host->getDuid()); } } diff --git a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h index e4e98f27ac..dd1b7ecb96 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h +++ b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h @@ -27,7 +27,7 @@ namespace isc { namespace dhcp { namespace bench { - /// @brief Base fixture class for benchmarking host bakcends. +/// @brief Base fixture class for benchmarking host bakcends. class GenericHostDataSourceBenchmark : public ::benchmark::Fixture { public: @@ -188,22 +188,36 @@ public: /// getAll(identifier-type, identifier) call. void benchGetAll(); - /// @brief Essential stpes requires to benchmark host reservation retrieval + /// @brief Essential steps required to benchmark host reservation retrieval /// using getAll(ipv4-reservation) call. void getAllv4Resv(); + /// @brief Essential steps requires to benchmark host reservation retrieval + /// using getAll(hw-addr, duid) call. void benchGet4BySubnetHWAddrDuid(); + /// @brief Essential steps requires to benchmark host reservation retrieval + /// using getAll(identifier-type, identifier, subnet-id) call. void benchGet4IdentifierSubnetId(); + /// @brief Essential steps requires to benchmark host reservation retrieval + /// using getAll(v4-reservation) call. void benchGet4SubnetIdv4Resrv(); + /// @brief Essential steps requires to benchmark host reservation retrieval + /// using get6(subnet-id, duid, hw-addr) call. void benchGet6SubnetIdDuidHWAddr(); + /// @brief Essential steps requires to benchmark host reservation retrieval + /// using get6(identifier-type, identifier, subnet-id) call. void benchGet6IdentifierSubnetId(); + /// @brief Essential steps requires to benchmark host reservation retrieval + /// using get6(ip-addr, subnet-id) call. void benchGet6SubnetIdAddr(); + /// @brief Essential steps requires to benchmark host reservation retrieval + /// using get6(prefix, len) call. void benchGet6Prefix(); /// Pointer to the host backend being benchmarked diff --git a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h index 5b3356260d..eb4de3926e 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h +++ b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h @@ -26,23 +26,6 @@ namespace isc { namespace dhcp { namespace bench { -/// @defgroup memfile_params Benchmark parameters that define boundary values -/// for benchmarks. -/// -/// The range is defined as 512..65533. Google benchmark will pick a few specifc -/// values: 512, 4096, 32768, 65533. - -/// @{ - -/// @brief A minimum number of leases used in a benchmark -constexpr size_t MIN_LEASE_COUNT = 512; -/// @brief A maximum number of leases used in a benchmark -constexpr size_t MAX_LEASE_COUNT = 0xfffd; -/// @brief A time unit used - all results to be expressed in us (microseconds) -constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond; - -/// @} - /// @brief A base class for a fixture for specific lease manager benchmarks class GenericLeaseMgrBenchmark : public benchmark::Fixture { public: diff --git a/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc index 8d61a10742..11b0655510 100644 --- a/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/memfile_lease_mgr_benchmark.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -14,8 +15,6 @@ using namespace isc::dhcp; using namespace isc::dhcp::test; using namespace isc::dhcp::bench; -using isc::dhcp::LeaseMgrFactory; -using isc::dhcp::bench::GenericLeaseMgrBenchmark; namespace { diff --git a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc index d26704926c..4eb39ce621 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc @@ -17,23 +17,26 @@ #include #include +#include #include #include #include -using isc::dhcp::bench::GenericHostDataSourceBenchmark; -using isc::dhcp::test::createMySQLSchema; -using isc::dhcp::test::destroyMySQLSchema; -using isc::dhcp::HostDataSourceFactory; -using isc::dhcp::test::validMySQLConnectionString; -using std::cerr; -using std::endl; +using namespace isc::dhcp::bench; +using namespace isc::dhcp::test; +using namespace isc::dhcp; +using namespace std; namespace { +/// @brief This is a fixture class used for benchmarking MySQL host backend class MySqlHostDataSourceBenchmark : public GenericHostDataSourceBenchmark { public: + + /// @brief Setup routine. + /// + /// It cleans up schema and recreates tables, then instantiates LeaseMgr void SetUp(::benchmark::State const&) override { destroyMySQLSchema(false); createMySQLSchema(false); @@ -47,6 +50,7 @@ public: hdsptr_ = HostDataSourceFactory::getHostDataSourcePtr(); } + /// @brief Cleans up after the test. void TearDown(::benchmark::State const&) override { try { hdsptr_->rollback(); @@ -60,6 +64,8 @@ public: } }; +/// Defines steps necessary for conducting a benchmark that measures +/// hosts insertion. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -68,6 +74,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, insertHosts)(benchmark::State& } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts update. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, updateHosts)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -76,6 +84,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, updateHosts)(benchmark::State& } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by getAll(hw-addr, duid) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -84,6 +94,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid)(benchmark:: } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by getAll4(hw-addr, duid) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAll)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -92,6 +104,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAll)(benchmark::State& state } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by getAll(v4-reservation) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -100,6 +114,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get4(subnet-id, hw-addr, duid) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -108,6 +124,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)(benchma } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -116,6 +134,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchma } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get4(subnet-id, v4-reservation) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -124,6 +144,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark: } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(subnet-id, duid, hw-addr) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -132,6 +154,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)(benchma } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -140,6 +164,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchma } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(subnet-id, ip-address) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -148,6 +174,8 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::St } } +/// Defines steps necessary for conducting a benchmark that measures +/// hosts retrieval by get6(ip-prefix, prefix-len) call. BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& state) { const size_t host_count = state.range(0); while (state.KeepRunning()) { @@ -156,21 +184,64 @@ BENCHMARK_DEFINE_F(MySqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& s } } -constexpr size_t MIN_HOST_COUNT = 512; -constexpr size_t MAX_HOST_COUNT = 0xfffd; -constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond; - -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, insertHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, updateHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAll)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllv4Resv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6Prefix)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); +/// Defines parameters necessary for running a benchmark that measures +/// hosts insertion. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, insertHosts) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts update. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, updateHosts) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll(hw-addr, duid) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllByHWAddrDuid) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll4(hw-addr, duid) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAll) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll(v4-reservation) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, getAllv4Resv) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(subnet-id, hw-addr, duid) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4IdentifierSubnetId) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(subnet-id, v4-reservation) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get4SubnetIdv4Resrv) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, duid, hw-addr) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6IdentifierSubnetId) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, ip-address) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6SubnetIdAddr) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(ip-prefix, prefix-len) call. +BENCHMARK_REGISTER_F(MySqlHostDataSourceBenchmark, get6Prefix) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); } // namespace diff --git a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc index 1bbe6151fe..0c88e25585 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc @@ -17,14 +17,14 @@ #include #include +#include #include #include using namespace isc::dhcp::bench; using namespace isc::dhcp::test; +using namespace isc::dhcp; using namespace std; -using isc::dhcp::LeaseMgrFactory; -//using isc::dhcp::bench::GenericLeaseMgrBenchmark; namespace { diff --git a/src/lib/dhcpsrv/benchmarks/parameters.h b/src/lib/dhcpsrv/benchmarks/parameters.h new file mode 100644 index 0000000000..5a321a7264 --- /dev/null +++ b/src/lib/dhcpsrv/benchmarks/parameters.h @@ -0,0 +1,43 @@ +// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef BENCHMARKS_PARAMETERS_H +#define BENCHMARKS_PARAMETERS_H + +#include + +namespace isc { +namespace dhcp { +namespace bench { + +/// @defgroup benchmark_params Benchmark parameters that define boundary values +/// for benchmarks. +/// +/// The range is defined as 512..65533. Google benchmark will pick a few specifc +/// values: 512, 4096, 32768, 65533. + +/// @{ + +/// @brief A minimum number of leases used in a benchmark +constexpr size_t MIN_LEASE_COUNT = 512; +/// @brief A maximum number of leases used in a benchmark +constexpr size_t MAX_LEASE_COUNT = 0xfffd; + + /// @brief A minimum number of leases used in a benchmark +constexpr size_t MIN_HOST_COUNT = 512; +/// @brief A maximum number of leases used in a benchmark +constexpr size_t MAX_HOST_COUNT = 0xfffd; + +/// @brief A time unit used - all results to be expressed in us (microseconds) +constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond; + +/// @} + +}; +}; +}; + +#endif diff --git a/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc index eac8094960..5245e9d6d8 100644 --- a/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/pgsql_host_data_source_benchmark.cc @@ -17,18 +17,15 @@ #include #include +#include #include #include - #include -using isc::dhcp::bench::GenericHostDataSourceBenchmark; -using isc::dhcp::test::createPgSQLSchema; -using isc::dhcp::test::destroyPgSQLSchema; -using isc::dhcp::HostDataSourceFactory; -using isc::dhcp::test::validPgSQLConnectionString; -using std::cerr; -using std::endl; +using namespace isc::dhcp::bench; +using namespace isc::dhcp::test; +using namespace isc::dhcp; +using namespace std; namespace { @@ -156,21 +153,64 @@ BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& s } } -constexpr size_t MIN_HOST_COUNT = 512; -constexpr size_t MAX_HOST_COUNT = 0xfffd; -constexpr benchmark::TimeUnit UNIT = benchmark::kMicrosecond; - -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, insertHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, updateHosts)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllByHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAll)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); -BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6Prefix)->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); +/// Defines parameters necessary for running a benchmark that measures +/// hosts insertion. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, insertHosts) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts update. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, updateHosts) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll(hw-addr, duid) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllByHWAddrDuid) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll4(hw-addr, duid) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAll) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by getAll(v4-reservation) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllv4Resv) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(subnet-id, hw-addr, duid) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4BySubnetHWAddrDuid) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(identifier-type, identifier, subnet-id) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get4(subnet-id, v4-reservation) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, duid, hw-addr) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdDuidHWAddr) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, identifier-type, identifier) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(subnet-id, ip-address) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); + +/// Defines parameters necessary for running a benchmark that measures +/// hosts retrieval by get6(ip-prefix, prefix-len) call. +BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6Prefix) + ->Range(MIN_HOST_COUNT, MAX_HOST_COUNT)->Unit(UNIT); } // namespace diff --git a/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc index d73c1b5abe..4080b6a2d9 100644 --- a/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/pgsql_lease_mgr_benchmark.cc @@ -18,17 +18,14 @@ #include #include +#include #include #include using namespace isc::dhcp::bench; -using isc::dhcp::LeaseMgrFactory; -using isc::dhcp::bench::GenericLeaseMgrBenchmark; -using isc::dhcp::test::createPgSQLSchema; -using isc::dhcp::test::destroyPgSQLSchema; -using isc::dhcp::test::validPgSQLConnectionString; -using std::cerr; -using std::endl; +using namespace isc::dhcp; +using namespace isc::dhcp::test; +using namespace std; namespace { -- 2.47.2