Date: Thu, 29 Nov 2001 09:06:43 -0800 From: Luigi Rizzo <luigi@FreeBSD.org> To: Peter Wemm <peter@wemm.org> Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: NFS and unaligned accesses (was Re: cvs commit: src/sys/pci if_sis.c) Message-ID: <20011129090643.E19821@iguana.aciri.org> In-Reply-To: <20011129064805.C37793808@overcee.netplex.com.au> References: <20011128141510.A13586@iguana.aciri.org> <20011129064805.C37793808@overcee.netplex.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
[Peter suggested some code to test the performance impact of unaligned accesses] Interesting code, thanks Peter. I actually used it to check how bcopy() behaves for unaligned accesses, and the results are again very dependent on alignment (on my 1.5GHz P4, offset from 0 to 15 give different results, tabulated below, which repeat modulo 16). Sure, here I am mostly testing the cache, but the results seems to suggest that if there is a misalignment penalty, that affects bcopy as well. So to go back where this came from, and hopefully disprove what I always considered to be an urban legend: the "sis" and other drivers do an m_devget() (which involves a bcopy) to make sure that buffers are aligned (to a 32 bit boundary, probably) in the upper level layers. On architectures which trap on unaligned accesses there is no other way, but on the i386 at least, the bcopy() just makes you pays the cost of misalignment in advance (and even when you do not need e.g. because you are forwarding traffic or handling TCP, which has its own alignment constraints and more often than not ends up in userspace). The remedy seems as bad or worse than the evil. cheers luigi ---- execution time of a simple bcopy(src, dst+offset, 1500) --- offset time 0 2.018u 0.007s 0:02.19 91.7% 5+177k 0+0io 0pf+0w 1 8.251u 0.007s 0:08.84 93.3% 5+172k 0+0io 0pf+0w 2 8.273u 0.000s 0:08.83 93.6% 5+173k 0+0io 0pf+0w 3 8.211u 0.023s 0:08.90 92.4% 5+176k 0+0io 0pf+0w 4 3.694u 0.015s 0:03.97 93.1% 5+176k 0+0io 0pf+0w 5 8.330u 0.038s 0:08.96 93.3% 5+176k 0+0io 0pf+0w 6 8.331u 0.038s 0:08.99 92.9% 5+177k 0+0io 0pf+0w 7 8.346u 0.015s 0:09.00 92.7% 5+173k 0+0io 0pf+0w 8 2.721u 0.000s 0:02.90 93.7% 5+176k 0+0io 0pf+0w 9 8.360u 0.023s 0:08.97 93.4% 5+176k 0+0io 0pf+0w 10 8.349u 0.023s 0:08.94 93.5% 5+176k 0+0io 0pf+0w 11 8.337u 0.031s 0:08.99 92.9% 5+174k 0+0io 0pf+0w 12 3.690u 0.024s 0:03.96 93.6% 5+170k 0+0io 0pf+0w 13 8.385u 0.054s 0:09.02 93.4% 5+175k 0+0io 0pf+0w 14 8.409u 0.015s 0:09.02 93.2% 5+174k 0+0io 0pf+0w 15 8.365u 0.023s 0:09.01 93.0% 5+176k 0+0io 0pf+0w ----------------------------------+----------------------------------------- Luigi RIZZO, luigi@iet.unipi.it . ACIRI/ICSI (on leave from Univ. di Pisa) http://www.iet.unipi.it/~luigi/ . 1947 Center St, Berkeley CA 94704 Phone: (510) 666 2927 ----------------------------------+----------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011129090643.E19821>