From: Tomek Mrugalski Date: Tue, 5 Apr 2022 17:20:13 +0000 (+0200) Subject: [#1548] Benchmark code removed X-Git-Tag: Kea-2.1.5~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a43a83062409c0da337f6ee4677329aebec8e6e;p=thirdparty%2Fkea.git [#1548] Benchmark code removed --- diff --git a/configure.ac b/configure.ac index ba898dd2d8..8da7ce5b43 100644 --- a/configure.ac +++ b/configure.ac @@ -639,19 +639,6 @@ fi # variables. AX_ISC_GTEST -enable_benchmark="no" -BENCHMARK_INCLUDES= - -AC_ARG_WITH([benchmark-source], - [AS_HELP_STRING([--with-benchmark-source[[=PATH]]], - [location of the benchmark source])], - [enable_benchmark="yes" ; BENCHMARK_SOURCE="$withval"]) - -AC_ARG_WITH([benchmark], - [AS_HELP_STRING([--with-benchmark[[=PATH]]], - [specify a path to benchmark header files (PATH/include) and library (PATH/lib)])], - [benchmark_path="$withval"; enable_benchmark="yes"], [benchmark_path="no"]) - # Sets up for use of botan unless openssl is specified # sets variables CRYPTO_* AX_CRYPTO @@ -957,89 +944,6 @@ AC_CHECK_LIB(pthread, pthread_create,[ LDFLAGS="$LDFLAGS -lpthread" ], []) # Now that Crypto backend and Boost were done we can address TLS. AX_TLS -# -# Check availability of benchmark. -# -BENCHMARK_CPPFLAGS= -BENCHMARK_LDFLAGS= -BENCHMARK_LDADD= -DISTCHECK_BENCHMARK_CONFIGURE_FLAG= -BENCHMARK_VERSION="unknown" - -if test "x$enable_benchmark" = "xyes" ; then - - DISTCHECK_BENCHMARK_CONFIGURE_FLAG="--with-benchmark=$benchmark_path" - - if test -n "$with_benchmark_source" ; then - - if test "x$BENCHMARK_SOURCE" = "xyes" ; then - - AC_MSG_CHECKING([for benchmark source]) - # If not specified, try some common paths. - BENCHMARK_SOURCE= - for d in /usr/src/benchmark /usr/local /usr/pkg /opt /opt/local ; do - if test -f $d/src/benchmark.cc; then - BENCHMARK_SOURCE=$d - AC_MSG_RESULT([$BENCHMARK_SOURCE]) - break - fi - done - if test -z $BENCHMARK_SOURCE ; then - AC_MSG_ERROR([no benchmark source but it was selected]) - fi - else - if test ! -d $BENCHMARK_SOURCE/src; then - BENCHMARK_SOURCE=$BENCHMARK_SOURCE/benchmark - fi - if test -f $BENCHMARK_SOURCE/src/benchmark.cc; then - have_benchmark_source=yes - else - AC_MSG_ERROR([no benchmark source at $BENCHMARK_SOURCE]) - fi - fi - have_benchmark_source=yes - BENCHMARK_CPPFLAGS=`cat \${BENCHMARK_SOURCE}/build/src/CMakeFiles/benchmark.dir/flags.make | grep CXX_DEFINES | cut -d "=" -f 2` - BENCHMARK_LDADD="\$(BENCHMARK_SOURCE)/build/src/libbenchmark.a" - DISTCHECK_BENCHMARK_CONFIGURE_FLAG="--with-benchmark-source=$BENCHMARK_SOURCE" - BENCHMARK_INCLUDES="-I$BENCHMARK_SOURCE \ - -I$BENCHMARK_SOURCE/src \ - -I$BENCHMARK_SOURCE/include \ - -I$BENCHMARK_SOURCE/include/benchmark" - BENCHMARK_VERSION="$(basename $BENCHMARK_SOURCE)" - fi - - if test "$benchmark_path" != "no" ; then - if test "$benchmark_path" != "yes"; then - BENCHMARK_PATHS=$benchmark_path - fi - if test -z "${BENCHMARK_PATHS}" ; then - BENCHMARK_PATHS="/usr /usr/local" - fi - BENCHMARK_FOUND="false" - for dir in ${BENCHMARK_PATHS}; do - if test -f "$dir/include/benchmark/benchmark.h"; then - if ! test -f "$dir/lib/libbenchmark.a"; then - AC_MSG_WARN([Found Google Benchmark include but not the library in $dir.]) - continue - fi - BENCHMARK_INCLUDES="-I$dir/include" - BENCHMARK_LDFLAGS="-L$dir/lib" - BENCHMARK_LDADD="$dir/lib/libbenchmark.a " - BENCHMARK_FOUND="true" - break - fi - done - if test "${BENCHMARK_FOUND}" != "true"; then - AC_MSG_ERROR([Cannot find benchmark in: $BENCHMARK_PATHS]) - fi - - fi - - if test $enable_gtest = no; then - AC_MSG_ERROR([--with-benchmark and --with-benchmark-source require --with-gtest or --with-gtest-source]) - fi - -fi AM_CONDITIONAL(HAVE_BENCHMARK, test $enable_benchmark != "no") AM_CONDITIONAL(HAVE_BENCHMARK_SOURCE, test "X$have_benchmark_source" = "Xyes") AC_SUBST(DISTCHECK_BENCHMARK_CONFIGURE_FLAG) @@ -1619,7 +1523,6 @@ AC_CONFIG_FILES([src/lib/dhcp/tests/Makefile]) AC_CONFIG_FILES([src/lib/dhcp_ddns/Makefile]) AC_CONFIG_FILES([src/lib/dhcp_ddns/tests/Makefile]) AC_CONFIG_FILES([src/lib/dhcpsrv/Makefile]) -AC_CONFIG_FILES([src/lib/dhcpsrv/benchmarks/Makefile]) AC_CONFIG_FILES([src/lib/dhcpsrv/tests/Makefile]) AC_CONFIG_FILES([src/lib/dhcpsrv/tests/test_libraries.h]) AC_CONFIG_FILES([src/lib/dhcpsrv/testutils/Makefile]) @@ -1999,25 +1902,6 @@ Google Test: END fi -if test "$enable_benchmark" != "no"; then -cat >> config.report << END - -Google Benchmark: - BENCHMARK_VERSION: ${BENCHMARK_VERSION} - BENCHMARK_CPPFLAGS: ${BENCHMARK_CPPFLAGS} - BENCHMARK_INCLUDES: ${BENCHMARK_INCLUDES} - BENCHMARK_LDFLAGS: ${BENCHMARK_LDFLAGS} - BENCHMARK_LDADD: ${BENCHMARK_LDADD} - BENCHMARK_SOURCE: ${BENCHMARK_SOURCE} -END -else -cat >> config.report << END - -Google Benchmark: - no -END -fi - if test "$FREERADIUS_INCLUDE" != ""; then cat >> config.report << END diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am index 6bf83ccfcd..f1cdbbfc44 100644 --- a/src/lib/dhcpsrv/Makefile.am +++ b/src/lib/dhcpsrv/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = subdir-objects -SUBDIRS = . testutils tests benchmarks +SUBDIRS = . testutils tests # DATA_DIR is the directory where to put default CSV files and the DHCPv6 # server ID file (i.e. the file where the server finds its DUID at startup). diff --git a/src/lib/dhcpsrv/benchmarks/.gitignore b/src/lib/dhcpsrv/benchmarks/.gitignore deleted file mode 100644 index f2f79655f8..0000000000 --- a/src/lib/dhcpsrv/benchmarks/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/run-benchmarks - diff --git a/src/lib/dhcpsrv/benchmarks/Makefile.am b/src/lib/dhcpsrv/benchmarks/Makefile.am deleted file mode 100644 index cb61846f26..0000000000 --- a/src/lib/dhcpsrv/benchmarks/Makefile.am +++ /dev/null @@ -1,104 +0,0 @@ -SUBDIRS = . - -AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib -AM_CPPFLAGS += $(BOOST_INCLUDES) -AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/dhcpsrv/tests\" - -AM_CXXFLAGS = $(KEA_CXXFLAGS) - -if USE_STATIC_LINK -AM_LDFLAGS = -static -endif - -CLEANFILES = *.gcno *.gcda - -EXTRA_DIST = benchmarks.dox - -BENCHMARKS= -if HAVE_BENCHMARK - -BENCHMARKS += run-benchmarks - -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 -run_benchmarks_SOURCES += mysql_host_data_source_benchmark.cc -endif - -if HAVE_PGSQL -run_benchmarks_SOURCES += pgsql_lease_mgr_benchmark.cc -run_benchmarks_SOURCES += pgsql_host_data_source_benchmark.cc -endif - -run_benchmarks_CPPFLAGS = $(AM_CPPFLAGS) $(BENCHMARK_INCLUDES) $(BENCHMARK_CPPFLAGS) - -if HAVE_MYSQL -run_benchmarks_CPPFLAGS += $(MYSQL_CPPFLAGS) -endif - -if HAVE_PGSQL -run_benchmarks_CPPFLAGS += $(PGSQL_CPPFLAGS) -endif - -run_benchmarks_CXXFLAGS = $(AM_CXXFLAGS) - -run_benchmarks_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(BENCHMARK_LDFLAGS) - -if HAVE_MYSQL -run_benchmarks_LDFLAGS += $(MYSQL_LIBS) -endif - -if HAVE_PGSQL -run_benchmarks_LDFLAGS += $(PGSQL_LIBS) -endif - -run_benchmarks_LDADD = $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/process/libkea-process.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/http/libkea-http.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la - -if HAVE_MYSQL -run_benchmarks_LDADD += $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la -endif - -if HAVE_PGSQL -run_benchmarks_LDADD += $(top_builddir)/src/lib/pgsql/testutils/libpgsqltest.la -endif - -run_benchmarks_LDADD += $(top_builddir)/src/lib/database/libkea-database.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/log/libkea-log.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/util/libkea-util.la -run_benchmarks_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la - -if HAVE_MYSQL -run_benchmarks_LDADD += $(MYSQL_LIBS) -endif - -if HAVE_PGSQL -run_benchmarks_LDADD += $(PGSQL_LIBS) -endif - -run_benchmarks_LDADD += $(LOG4CPLUS_LIBS) -run_benchmarks_LDADD += $(CRYPTO_LIBS) -run_benchmarks_LDADD += $(BOOST_LIBS) -run_benchmarks_LDADD += $(GTEST_LDADD) -run_benchmarks_LDADD += $(BENCHMARK_LDADD) - -endif - -noinst_PROGRAMS = $(BENCHMARKS) diff --git a/src/lib/dhcpsrv/benchmarks/benchmarks.dox b/src/lib/dhcpsrv/benchmarks/benchmarks.dox deleted file mode 100644 index 3582079f9e..0000000000 --- a/src/lib/dhcpsrv/benchmarks/benchmarks.dox +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (C) 2018-2021 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/. - -/** - @page benchmarks Benchmarks: Measuring performance - -@section benchmarksOverview - -Kea 1.4 added support for benchmarks. We are using -Google Benchmark -framework. See their webpage for overview and details. - -To compile benchmarks, configure Kea with appropriate flag: - -@code -$ ./configure --with-benchmark -$ make -@endcode - -The benchmarks are built in @b src/lib/dhcpsrv/benchmarks directory. -Note that the benchmarks are backend-specific, so please make sure you -enable the backends you want to measure (See --with-mysql and --with-pgsql -parameters for configure). Once the benchmark is built, you can run specific -benchmarks. Make sure you have the environment ready for use, i.e. the actual -database backend is set up, the DB is created. The setup is the same -as for running unit-tests. DB name should be keatest, and username -keatest, password keatest should give you full write access to the database. -Any data present in the DB before the tests will be removed. - -To get a list of available benchmarks, use the following command: - -@code -$ cd src/lib/dhcpsrv/benchmarks -$ ./run-benchmarks --benchmark_list_tests -@endcode - -The list is dependant on the configuration flags and availability of -various backends. For example, to run specific benchmark you may -specify its name. Wildcards are supported: - -@code -# This will run one specific benchmark -$ ./run-benchmarks --benchmark_filter=MemfileLeaseMgrBenchmark/insertLeases4/512 - -# This will run all benchmarks related to MySql: -$ ./run-benchmarks --benchmark_filter=MySqlHostDataSourceBenchmark - -@endcode - -It takes a long time to run some benchmarks, so please make sure you run only -those you are interested in. For example, this is the output of all memfile -benchmarks: - -@code -$ ./run-benchmarks --benchmark_filter=MemfileLeaseMgrBenchmark -Run on (8 X 3800 MHz CPU s) -2018-01-23 21:00:19 -***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead. -***WARNING*** Library was built as DEBUG. Timings may be affected. -------------------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------------------- -MemfileLeaseMgrBenchmark/insertLeases4/512 10716 us 10716 us 48 -MemfileLeaseMgrBenchmark/insertLeases4/4096 90593 us 90590 us 8 -MemfileLeaseMgrBenchmark/insertLeases4/32768 758551 us 758524 us 1 -MemfileLeaseMgrBenchmark/insertLeases4/65533 1553195 us 1553136 us 1 -MemfileLeaseMgrBenchmark/updateLeases4/512 8379 us 8379 us 84 -MemfileLeaseMgrBenchmark/updateLeases4/4096 67506 us 67504 us 10 -MemfileLeaseMgrBenchmark/updateLeases4/32768 546041 us 546024 us 1 -MemfileLeaseMgrBenchmark/updateLeases4/65533 1098839 us 1098799 us 1 -MemfileLeaseMgrBenchmark/getLease4_address/512 2772 us 2772 us 253 -MemfileLeaseMgrBenchmark/getLease4_address/4096 23407 us 23406 us 30 -MemfileLeaseMgrBenchmark/getLease4_address/32768 179624 us 179619 us 4 -MemfileLeaseMgrBenchmark/getLease4_address/65533 393543 us 393531 us 2 -MemfileLeaseMgrBenchmark/getLease4_hwaddr/512 3899 us 3898 us 181 -MemfileLeaseMgrBenchmark/getLease4_hwaddr/4096 51317 us 51316 us 12 -MemfileLeaseMgrBenchmark/getLease4_hwaddr/32768 3269266 us 3269150 us 1 -MemfileLeaseMgrBenchmark/getLease4_hwaddr/65533 13225744 us 13225237 us 1 -MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/512 3501 us 3501 us 201 -MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/4096 30573 us 30571 us 23 -MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/32768 245307 us 245295 us 3 -MemfileLeaseMgrBenchmark/getLease4_hwaddr_subnetid/65533 521296 us 521274 us 1 -MemfileLeaseMgrBenchmark/getLease4_clientid/512 3999 us 3999 us 175 -MemfileLeaseMgrBenchmark/getLease4_clientid/4096 75467 us 75464 us 9 -MemfileLeaseMgrBenchmark/getLease4_clientid/32768 6375617 us 6375402 us 1 -MemfileLeaseMgrBenchmark/getLease4_clientid/65533 26109513 us 26108636 us 1 -MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/512 3532 us 3532 us 198 -MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/4096 30279 us 30277 us 24 -MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/32768 244085 us 244072 us 3 -MemfileLeaseMgrBenchmark/getLease4_clientid_subnetid/65533 509971 us 509948 us 1 -MemfileLeaseMgrBenchmark/getExpiredLeases4/512 837 us 837 us 841 -MemfileLeaseMgrBenchmark/getExpiredLeases4/4096 72253 us 72251 us 8 -MemfileLeaseMgrBenchmark/getExpiredLeases4/32768 5837125 us 5836712 us 1 -MemfileLeaseMgrBenchmark/getExpiredLeases4/65533 42295069 us 42292723 us 1 -MemfileLeaseMgrBenchmark/insertLeases6/512 5638 us 5638 us 121 -MemfileLeaseMgrBenchmark/insertLeases6/4096 46669 us 46667 us 15 -MemfileLeaseMgrBenchmark/insertLeases6/32768 423543 us 423527 us 2 -MemfileLeaseMgrBenchmark/insertLeases6/65533 806061 us 806031 us 1 -MemfileLeaseMgrBenchmark/updateLeases6/512 2796 us 2796 us 231 -MemfileLeaseMgrBenchmark/updateLeases6/4096 22683 us 22681 us 31 -MemfileLeaseMgrBenchmark/updateLeases6/32768 190410 us 190403 us 4 -MemfileLeaseMgrBenchmark/updateLeases6/65533 382458 us 382441 us 2 -MemfileLeaseMgrBenchmark/getLease6_type_address/512 2824 us 2824 us 246 -MemfileLeaseMgrBenchmark/getLease6_type_address/4096 23483 us 23482 us 30 -MemfileLeaseMgrBenchmark/getLease6_type_address/32768 198815 us 198800 us 4 -MemfileLeaseMgrBenchmark/getLease6_type_address/65533 369424 us 369408 us 2 -MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/512 3859 us 3858 us 183 -MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/4096 32180 us 32178 us 23 -MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/32768 252381 us 252372 us 3 -MemfileLeaseMgrBenchmark/getLease6_type_duid_iaid/65533 508467 us 508449 us 2 -MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/512 4085 us 4085 us 170 -MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/4096 32983 us 32981 us 21 -MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/32768 257658 us 257648 us 3 -MemfileLeaseMgrBenchmark/getLease6_type_type_duid_iaid_subnetid/65533 514603 us 514583 us 1 -MemfileLeaseMgrBenchmark/getExpiredLeases6/512 728 us 728 us 991 -MemfileLeaseMgrBenchmark/getExpiredLeases6/4096 66537 us 66535 us 11 -MemfileLeaseMgrBenchmark/getExpiredLeases6/32768 4645828 us 4645641 us 1 -MemfileLeaseMgrBenchmark/getExpiredLeases6/65533 23793972 us 23793017 us 1 -@endcode - -The results are to be interpreted as follows: - -@code -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------------------- -MemfileLeaseMgrBenchmark/insertLeases4/512 10716 us 10716 us 4 -@endcode - -- MemfileLeaseMgrBenchmark - This is a benchmark for memfile lease manager -- insertLeases4 - this benchmark tests performance of repeated lease insertion for many leases -- 512 - this is the number of leases that were inserted -- 10716 us - This is the average time it takes to insert 512 leases. us stands for microseconds, so that's - a bit over 10 milliseconds. -- 4 - Benchmark decided to repeat the number of iterations 4 times. - -@section benchmarksCode Internal code organization - -Benchmarks used isc::dhcp::bench namespace. - -Source code for the benchmarks reside in src/lib/dhcpsrv/benchmarks directory, -although due to similarity with unit tests, some code from testutils is reused. -Similar to unit-tests for lease managers and host data sources, there are -generic classes that handle a given manager. See -@ref isc::dhcp::bench::GenericHostDataSourceBenchmark and -@ref isc::dhcp::bench::GenericLeaseMgrBenchmark. These classes provide a unified -implementation for specific benchmarks, like IPv4 lease insertion. There is a -number of basic operations that are expected to be implemented in each backend. -Please look for methods that start with bench* prefix in the generic classes. - -@section benchmarkControlFlow Explaining control flow in benchmarks - -@todo: We should explain how the benchmarks are actually run, what does the state -parameter passed actually represent, why the setup code needs to be reentrant etc. - -@section benchmarkNew Adding new benchmarks - -The following is a loose description of all the steps necessary for implementing -a new benchmark. - --# Assuming the benchmark could in principle be run on several backends (all -benchmarks should, otherwise the major benefit of comparing different backends -would disappear), there should be a method in the base class (either -@ref isc::dhcp::bench::GenericHostDataSourceBenchmark or -@ref isc::dhcp::bench::GenericLeaseMgrBenchmark). See -@ref isc::dhcp::bench::GenericLeaseMgrBenchmark::benchUpdateLeases4 as an example. - --# You need to define a benchmark suing BENCHMARK_DEFINE_F macro. This should be -done in the backend specific file. For example: - @code - // Defines a benchmark that measures IPv4 leases update. - BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) { - const size_t lease_count = state.range(0); - while (state.KeepRunning()) { - ReentrantSetUpWithInserts4(state, lease_count); - benchUpdateLeases4(); - } - } - @endcode - --# You need to define boundary parameters for the benchmark that was defined -in step 2. For example: - @code - /// A benchmark that measures IPv4 leases update. - BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, updateLeases4) - ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT); - @endcode - This macro defines a range. For this particular example, MIN_LEASE_COUNT is 256 - and MAX_LEASE_COUNT is 65533. Google benchmark will pick several values in that - range (512, 4096, 32768 and 65533). As a result, the following new benchmarks - will become available: - @code - MemfileLeaseMgrBenchmark/updateLeases4/512 - MemfileLeaseMgrBenchmark/updateLeases4/4096 - MemfileLeaseMgrBenchmark/updateLeases4/32768 - MemfileLeaseMgrBenchmark/updateLeases4/65533 - @endcode - Those can be run from the command line using --benchmark_filter switch. - -*/ diff --git a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc deleted file mode 100644 index 59eb75323f..0000000000 --- a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") -// Copyright (C) 2017 Deutsche Telekom AG. -// -// Authors: Andrei Pavel -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using isc::asiolink::IOAddress; -using isc::dhcp::test::HostDataSourceUtils; -using std::cerr; -using std::endl; - -namespace isc { -namespace dhcp { -namespace bench { - -GenericHostDataSourceBenchmark::GenericHostDataSourceBenchmark() : hdsptr_() { - LibDHCP::clearRuntimeOptionDefs(); -} - -GenericHostDataSourceBenchmark::~GenericHostDataSourceBenchmark() { - LibDHCP::clearRuntimeOptionDefs(); - hdsptr_.reset(); -} - -void -GenericHostDataSourceBenchmark::setUp(::benchmark::State& state, size_t const& host_count) { - state.PauseTiming(); - SetUp(state); - prepareHosts(host_count); - state.ResumeTiming(); -} - -void -GenericHostDataSourceBenchmark::setUpWithInserts(::benchmark::State& state, - size_t const& host_count) { - state.PauseTiming(); - SetUp(state); - prepareHosts(host_count); - insertHosts(); - state.ResumeTiming(); -} - -OptionDescriptor -GenericHostDataSourceBenchmark::createEmptyOption(const Option::Universe& universe, - const uint16_t option_type, - const bool persist) const { - OptionPtr option(new Option(universe, option_type)); - OptionDescriptor desc(option, persist); - return desc; -} - -OptionDescriptor -GenericHostDataSourceBenchmark::createVendorOption(const Option::Universe& universe, - const bool persist, - const bool formatted, - const uint32_t vendor_id) const { - OptionVendorPtr option(new OptionVendor(universe, vendor_id)); - - std::ostringstream s; - if (formatted) { - // Vendor id comprises vendor-id field, for which we need to - // assign a value in the textual (formatted) format. - s << vendor_id; - } - - OptionDescriptor desc(option, persist, s.str()); - return desc; -} - -void -GenericHostDataSourceBenchmark::addTestOptions(const HostPtr& host, - const bool formatted, - const AddedOptions& added_options) const { - OptionDefSpaceContainer defs; - - if ((added_options == DHCP4_ONLY) || (added_options == DHCP4_AND_DHCP6)) { - // Add DHCPv4 options. - CfgOptionPtr opts = host->getCfgOption4(); - opts->add(createOption(Option::V4, DHO_BOOT_FILE_NAME, - true, formatted, "my-boot-file"), - DHCP4_OPTION_SPACE); - opts->add(createOption(Option::V4, DHO_DEFAULT_IP_TTL, - false, formatted, 64), - DHCP4_OPTION_SPACE); - opts->add(createOption(Option::V4, 1, false, formatted, 312131), - "vendor-encapsulated-options"); - opts->add(createAddressOption(254, false, formatted, "192.0.2.3"), - DHCP4_OPTION_SPACE); - opts->add(createEmptyOption(Option::V4, 1, true), "isc"); - opts->add(createAddressOption(2, false, formatted, - "10.0.0.5", "10.0.0.3", - "10.0.3.4"), "isc"); - - // Add definitions for DHCPv4 non-standard options. - defs.addItem(OptionDefinitionPtr(new OptionDefinition("vendor-encapsulated-1", - 1, "vendor-encapsulated-options", "uint32"))); - defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-254", 254, - DHCP4_OPTION_SPACE, "ipv4-address", true))); - defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "isc", "empty"))); - defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, - "isc", "ipv4-address", true))); - } - - if ((added_options == DHCP6_ONLY) || (added_options == DHCP4_AND_DHCP6)) { - // 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"), - DHCP6_OPTION_SPACE); - opts->add(createEmptyOption(Option::V6, 1, true), "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, - DHCP6_OPTION_SPACE, "ipv6-address", true))); - defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1", 1, "isc2", "empty"))); - defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2, - "isc2", "ipv6-address", true))); - } - - // Register created "runtime" option definitions. They will be used by a - // host data source to convert option data into the appropriate option - // classes when the options are retrieved. - LibDHCP::setRuntimeOptionDefs(defs); -} - -void -GenericHostDataSourceBenchmark::prepareHosts(size_t const& host_count) { - if (host_count > 0xfffdu) { - cerr << "host_count <= 0xfffd or change address xgeneration in " - "GenericLeaseMgrBenchmark::prepareLeases6()" - << endl; - } - hosts_.clear(); - for (size_t i = 0x0001u; i < 0x0001u + host_count; ++i) { - std::stringstream ss; - std::string n_host; - ss << std::hex << i; - ss >> n_host; - - const std::string prefix = std::string("2001:db8::") + n_host; - HostPtr host = HostDataSourceUtils::initializeHost6(prefix, Host::IDENT_HWADDR, false); - addTestOptions(host, false, DHCP4_AND_DHCP6); - hosts_.push_back(host); - } -} - -void -GenericHostDataSourceBenchmark::insertHosts() { - for (HostPtr host : hosts_) { - hdsptr_->add(host); - } -} - -void -GenericHostDataSourceBenchmark::benchGetAll() { - for (HostPtr host : hosts_) { - std::vector hwaddr = host->getIdentifier(); - hdsptr_->getAll(host->getIdentifierType(), &hwaddr[0], hwaddr.size()); - } -} - -void -GenericHostDataSourceBenchmark::getAllv4Resv() { - for (HostPtr host : hosts_) { - hdsptr_->getAll4(host->getIPv4Reservation()); - } -} - -void -GenericHostDataSourceBenchmark::benchGet4IdentifierSubnetId() { - for (HostPtr host : hosts_) { - std::vector hwaddr = host->getIdentifier(); - hdsptr_->get4(host->getIPv4SubnetID(), host->getIdentifierType(), - &hwaddr[0], hwaddr.size()); - } -} - -void -GenericHostDataSourceBenchmark::benchGet4SubnetIdv4Resrv() { - for (HostPtr host : hosts_) { - hdsptr_->get4(host->getIPv4SubnetID(), host->getIPv4Reservation()); - } -} - -void -GenericHostDataSourceBenchmark::benchGet6IdentifierSubnetId() { - for (HostPtr host : hosts_) { - std::vector hwaddr = host->getIdentifier(); - hdsptr_->get6(host->getIPv6SubnetID(), host->getIdentifierType(), - &hwaddr[0], hwaddr.size()); - } -} - -void -GenericHostDataSourceBenchmark::benchGet6SubnetIdAddr() { - for (HostPtr host : hosts_) { - const IPv6ResrvRange range = host->getIPv6Reservations(); - hdsptr_->get6(host->getIPv6SubnetID(), range.first->second.getPrefix()); - } -} - -void -GenericHostDataSourceBenchmark::benchGet6Prefix() { - for (HostPtr host : hosts_) { - const IPv6ResrvRange range = host->getIPv6Reservations(); - hdsptr_->get6(range.first->second.getPrefix(), - range.first->second.getPrefixLen()); - } -} - -} // namespace bench -} // namespace dhcp -} // namespace isc diff --git a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h deleted file mode 100644 index d5bfa7ef65..0000000000 --- a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.h +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") -// Copyright (C) 2017 Deutsche Telekom AG. -// -// Authors: Andrei Pavel -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef GENERIC_HOST_DATA_SOURCE_UNITTEST_H -#define GENERIC_HOST_DATA_SOURCE_UNITTEST_H - -#include - -#include -#include - -namespace isc { -namespace dhcp { -namespace bench { - -/// @brief Base fixture class for benchmarking host backends. -class GenericHostDataSourceBenchmark : public ::benchmark::Fixture { -public: - /// @brief Defines universe (IPv4 or IPv6) - enum Universe { V4, V6 }; - - /// @brief Defines what kind of options should be added for a host - enum AddedOptions { - DHCP4_ONLY, ///< DHCPv4-only options - DHCP6_ONLY, ///< DHCPv6-only options - DHCP4_AND_DHCP6 ///< Both DHCPv4 and DHCPv6 options - }; - - /// @brief Constructor - /// - /// Clears runtime option definitions. - GenericHostDataSourceBenchmark(); - - /// @brief Destructor - /// - /// Clears runtime option definitions and clears hdsptr_ pointer. - virtual ~GenericHostDataSourceBenchmark(); - - /// @brief Creates a generic option with specific parameters. - /// - /// @param universe (v4 or v6) - /// @param option_type code of the option - /// @param persist whether the option should always be included (yes) or not (no) - /// @return the option created wrapped in an option descriptor structure - OptionDescriptor createEmptyOption(const Option::Universe& universe, - const uint16_t option_type, - const bool persist) const; - - /// @brief Creates an option of specified type and value - /// - /// @tparam OptionType Option class to be instantiated - /// @tparam DataType type of parameter to be passed to OptionType constructor - /// @param universe (v4 or v6) - /// @param option_type code of the option - /// @param persist whether the option should always be included (yes) or not (no) - /// @param formatted whether the value passed to description should be converted to text - /// @param value option value - /// @return the option created wrapped in an option descriptor structure - template - OptionDescriptor createOption(const Option::Universe& universe, - const uint16_t option_type, - const bool persist, - const bool formatted, - const DataType& value) const { - boost::shared_ptr