From owner-svn-src-head@freebsd.org Wed Jul 4 15:15:50 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C182104143B; Wed, 4 Jul 2018 15:15:50 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF9C3821AB; Wed, 4 Jul 2018 15:15:49 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w64FFmvv043459; Wed, 4 Jul 2018 08:15:48 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w64FFmXY043458; Wed, 4 Jul 2018 08:15:48 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201807041515.w64FFmXY043458@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r335941 - head/tools/tools/syscall_timing In-Reply-To: <201807041334.w64DYhQu007746@repo.freebsd.org> To: Edward Tomasz Napierala Date: Wed, 4 Jul 2018 08:15:48 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2018 15:15:50 -0000 > Author: trasz > Date: Wed Jul 4 13:34:43 2018 > New Revision: 335941 > URL: https://svnweb.freebsd.org/changeset/base/335941 > > Log: > Add a trivial "pipe ping" (two processes) benchmark. > > Obtained from: CheriBSD > MFC after: 2 weeks > Sponsored by: DARPA, AFRL > > Modified: > head/tools/tools/syscall_timing/syscall_timing.c > > Modified: head/tools/tools/syscall_timing/syscall_timing.c > ============================================================================== > --- head/tools/tools/syscall_timing/syscall_timing.c Wed Jul 4 13:31:55 2018 (r335940) > +++ head/tools/tools/syscall_timing/syscall_timing.c Wed Jul 4 13:34:43 2018 (r335941) > @@ -31,6 +31,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -251,6 +252,52 @@ test_select(uintmax_t num, uintmax_t int_arg __unused, > } > > static uintmax_t > +test_pipeping(uintmax_t num, uintmax_t int_arg, const char *path __unused) > +{ > + char buf[int_arg]; > + uintmax_t i; > + ssize_t ret; > + pid_t pid; > + int fd[2], procfd; > + > + if (pipe(fd) < 0) > + err(-1, "pipe"); > + > + pid = pdfork(&procfd, 0); > + if (pid < 0) > + err(1, "pdfork"); > + > + if (pid == 0) { > + close(fd[0]); > + > + for (;;) { > + ret = read(fd[1], buf, int_arg); > + if ((uintmax_t)ret != int_arg) > + err(1, "read"); > + ret = write(fd[1], buf, int_arg); > + if ((uintmax_t)ret != int_arg) > + err(1, "write"); > + } > + } > + > + close(fd[1]); > + > + benchmark_start(); > + BENCHMARK_FOREACH(i, num) { > + ret = write(fd[0], buf, int_arg); > + if ((uintmax_t)ret != int_arg) > + err(1, "write"); > + ret = read(fd[0], buf, int_arg); > + if ((uintmax_t)ret != int_arg) > + err(1, "read"); > + } > + benchmark_stop(); > + > + close(procfd); > + return (i); > +} > + > +static uintmax_t > test_socket_stream(uintmax_t num, uintmax_t int_arg, const char *path __unused) > { > uintmax_t i; > @@ -694,6 +741,18 @@ static const struct test tests[] = { > { "getppid", test_getppid, .t_flags = 0 }, > { "getresuid", test_getresuid, .t_flags = 0 }, > { "clock_gettime", test_clock_gettime, .t_flags = 0 }, > + { "pipeping_1", test_pipeping, .t_flags = 0, .t_int = 1 }, > + { "pipeping_10", test_pipeping, .t_flags = 0, .t_int = 10 }, > + { "pipeping_100", test_pipeping, .t_flags = 0, .t_int = 100 }, > + { "pipeping_1000", test_pipeping, .t_flags = 0, .t_int = 1000 }, > + { "pipeping_10000", test_pipeping, .t_flags = 0, .t_int = 10000 }, > +#ifdef notyet > + /* > + * XXX: Doesn't work; kernel pipe buffer too small? > + */ > + { "pipeping_100000", test_pipeping, .t_flags = 0, .t_int = 100000 }, > + { "pipeping_1000000", test_pipeping, .t_flags = 0, .t_int = 1000000 }, > + #endif Can you get the size of the pipe buffer and make a run time decision on this? Not all of us run with defaults.... Hum, does not seem it is easy to get this pipe size info from userland... > { "gettimeofday", test_gettimeofday, .t_flags = 0 }, > { "getpriority", test_getpriority, .t_flags = 0 }, > { "getprogname", test_getprogname, .t_flags = 0 }, > > -- Rod Grimes rgrimes@freebsd.org