From owner-dev-commits-src-main@freebsd.org Wed May 5 10:33:25 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AEC056396C1; Wed, 5 May 2021 10:33:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FZtN54d7Tz3hr4; Wed, 5 May 2021 10:33:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 91A682369D; Wed, 5 May 2021 10:33:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 145AXPIC002779; Wed, 5 May 2021 10:33:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 145AXPof002778; Wed, 5 May 2021 10:33:25 GMT (envelope-from git) Date: Wed, 5 May 2021 10:33:25 GMT Message-Id: <202105051033.145AXPof002778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marko Zec Subject: git: a43104ebe763 - main - Revise FIB lookups per second benchmarking routines. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a43104ebe7630111d7e7debc56aacf49787dcf43 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2021 10:33:25 -0000 The branch main has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=a43104ebe7630111d7e7debc56aacf49787dcf43 commit a43104ebe7630111d7e7debc56aacf49787dcf43 Author: Marko Zec AuthorDate: 2021-05-05 10:28:17 +0000 Commit: Marko Zec CommitDate: 2021-05-05 10:28:17 +0000 Revise FIB lookups per second benchmarking routines. Add a LPS benchmark variant which introduces artificial dependencies between successive lookups. While here, instead of writing the results from the lookups to a huge array, add them to an accumulator, in a more lightweight attempt at preventing the CPU's OOO machinery from discarding the lookup results if they would be completely unused. net.route.test.run_lps_rnd measures LPS throughput with independent uniformly random keys net.route.test.run_lps_seq measures LPS throughput with uniformly random keys with artificial interdependencies Reviewed by: melifaro MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D30096 --- sys/tests/fib_lookup/fib_lookup.c | 42 +++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/sys/tests/fib_lookup/fib_lookup.c b/sys/tests/fib_lookup/fib_lookup.c index ea07e3d697c6..4093ff9dd487 100644 --- a/sys/tests/fib_lookup/fib_lookup.c +++ b/sys/tests/fib_lookup/fib_lookup.c @@ -509,13 +509,13 @@ static int rnd_lps(SYSCTL_HANDLER_ARGS) { struct epoch_tracker et; - struct in_addr *keys; - struct nhop_object **nhops; - + struct in_addr key; struct timespec ts_pre, ts_post; uint64_t total_diff, lps; - int error; + uint32_t *keys; + uintptr_t acc = 0; int count = 0; + int error; error = sysctl_handle_int(oidp, &count, 0, req); if (error != 0) @@ -524,12 +524,8 @@ rnd_lps(SYSCTL_HANDLER_ARGS) return (0); keys = malloc(sizeof(*keys) * count, M_TEMP, M_NOWAIT); - nhops = malloc(sizeof(*nhops) * count, M_TEMP, M_NOWAIT); - if (keys == NULL || nhops == NULL) { - free(keys, M_TEMP); - free(nhops, M_TEMP); + if (keys == NULL) return (ENOMEM); - } printf("Preparing %d random keys...\n", count); arc4random_buf(keys, sizeof(*keys) * count); @@ -537,26 +533,42 @@ rnd_lps(SYSCTL_HANDLER_ARGS) NET_EPOCH_ENTER(et); nanouptime(&ts_pre); - for (int i = 0; i < count; i++) - nhops[i] = fib4_lookup(RT_DEFAULT_FIB, keys[i], 0, NHR_NONE, 0); + switch (arg2) { + case 0: + for (int i = 0; i < count; i++) { + key.s_addr = keys[i] + acc; + acc += (uintptr_t) fib4_lookup(RT_DEFAULT_FIB, key, 0, + NHR_NONE, 0); + } + case 1: + for (int i = 0; i < count; i++) { + key.s_addr = keys[i]; + acc += (uintptr_t) fib4_lookup(RT_DEFAULT_FIB, key, 0, + NHR_NONE, 0); + } + } nanouptime(&ts_post); NET_EPOCH_EXIT(et); free(keys, M_TEMP); - free(nhops, M_TEMP); total_diff = (ts_post.tv_sec - ts_pre.tv_sec) * 1000000000 + - (ts_post.tv_nsec - ts_pre.tv_nsec); + (ts_post.tv_nsec - ts_pre.tv_nsec) + (acc & 1); lps = 1000000000ULL * count / total_diff; printf("%d lookups in %zu nanoseconds, %lu.%06lu MLPS\n", count, total_diff, lps / 1000000, lps % 1000000); return (0); } -SYSCTL_PROC(_net_route_test, OID_AUTO, rnd_lps, +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_seq, CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, rnd_lps, "I", - "Measure lookups per second using uniformly random keys"); + "Measure lookups per second, uniformly random keys, " + "artificial dependencies between lookups"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_rnd, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, 1, rnd_lps, "I", + "Measure lookups per second, uniformly random keys, independent lookups"); static int test_fib_lookup_modevent(module_t mod, int type, void *unused)