Subject: NEWPIPE: benchmark performance diff microtime(9) vs. =
To: None <current-users@netbsd.org>
From: Jaromir Dolecek <jdolecek@netbsd.org>
List: current-users
Date: 10/24/2001 00:37:42
--ELM711936240-358-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
Hi,
Andreas Persson (submitter of kern/14246) found out that lot of
time is spent in microtime(9) when doing pipe i/o.
I did some testing and benchmarking using hbench and confirmed that
version of sys_pipe.c which avoids microtime(9) is roughly 100% to
200% faster than the one with microtime(9) for small buffers. The
performance difference on platforms with faster microtime(9) might
be smaller than the difference on i386. However, this could help
on all platforms a bit :)
I benchmarked the change on:
cpu0: Intel Pentium III (Coppermine) (686-class), 661.17 MHz
cpu0: I-cache 16 KB 32b/line 4-way, D-cache 16 KB 32b/line 2-way
I've run each item 5 times, ignored lowest and highest number
and made average of the remaining three. I've run hbench like this:
for i in 1 2 3 4 5; do
/usr/pkg/bin/hbench/netbsd1.5Y-i386/bw_pipe 100 buffersize
done
i.e. used 100 iterations 5 times.
Results (in MB/s) are below. 'microtime' is result with current
code using microtime(9). '=' is result with code using
*(tv) = time
instead of microtime(9). The '=b' is result when I bumped PIPE_MINDIRECT
to (2*PAGE_SIZE), i.e. on i386 the test for buffersize 4096 did not
use Page Loan.
buffersize microtime1 microtime2 =b1 =b2 =1 =2
512 17 17 43 55 - -
1024 35 31 136 83 - -
2048 54 51 157 129 - -
4096 77 77 160 165 106 106
8192 142 142 190 190 190 190
64K 577 577 662 662 - -
128K 372 371 392 391 - -
So, this change seems to be major win especially for small buffer
sizes (which is important for real-world applications), but helps
much for 'big' buffer sizes too. This should make our pipe performance
exceed e.g. FreeBSD's one, which was very close better according to previous
benchmarks.
I'm appending the patch. I recall someone (fvdl?) made some
tests before. He did a graphical graph from the results, which showed
the performance differencies between various OSes. It would be cool
if this graph would be updated with values from test with this change.
This change would probably get committed soon, too.
Jaromir
--
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.NetBSD.org/Ports/i386/ps2.html
-= Those who would give up liberty for a little temporary safety deserve =-
-= neither liberty nor safety, and will lose both. -- Benjamin Franklin =-
--ELM711936240-358-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=ISO-8859-2
Content-Disposition: attachment; filename=fff
Index: kern/sys_pipe.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/sys_pipe.c,v
retrieving revision 1.16
diff -u -p -r1.16 sys_pipe.c
--- kern/sys_pipe.c 2001/10/08 07:50:17 1.16
+++ kern/sys_pipe.c 2001/10/23 22:34:35
@@ -82,12 +82,18 @@
#include <sys/syscallargs.h>
#include <uvm/uvm.h>
#include <sys/sysctl.h>
+#include <sys/kernel.h>
#endif /* NetBSD, FreeBSD */
#include <sys/pipe.h>
#ifdef __NetBSD__
-#define vfs_timestamp(tv) microtime(tv)
+/*
+ * Avoid microtime(9), it's slow. We don't guard the read from time(9)
+ * with splclock(9) since we don't actually need to be THAT sure the access
+ * is atomic.
+ */
+#define vfs_timestamp(tv) (*(tv) = time)
#endif
/*
Index: sys/pipe.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/pipe.h,v
retrieving revision 1.7
diff -u -p -r1.7 pipe.h
--- sys/pipe.h 2001/07/23 19:34:36 1.7
+++ sys/pipe.h 2001/10/23 22:34:35
@@ -65,7 +65,7 @@
#if defined(__FreeBSD__)
#define PIPE_MINDIRECT 8192
#elif defined(__NetBSD__)
-#define PIPE_MINDIRECT PAGE_SIZE
+#define PIPE_MINDIRECT (2*PAGE_SIZE)
#endif
#endif
--ELM711936240-358-0_--