From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 12 09:14:45 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BEEED16A468 for ; Mon, 12 Nov 2007 09:14:45 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from fallbackmx01.syd.optusnet.com.au (fallbackmx01.syd.optusnet.com.au [211.29.132.93]) by mx1.freebsd.org (Postfix) with ESMTP id 40DAC13C4B2 for ; Mon, 12 Nov 2007 09:14:45 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from mail11.syd.optusnet.com.au (mail11.syd.optusnet.com.au [211.29.132.192]) by fallbackmx01.syd.optusnet.com.au (8.12.11.20060308/8.12.11) with ESMTP id lABIRpbl011487 for ; Mon, 12 Nov 2007 05:27:51 +1100 Received: from server.vk2pj.dyndns.org (c220-239-20-82.belrs4.nsw.optusnet.com.au [220.239.20.82]) by mail11.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id lABIQlJv003948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 12 Nov 2007 05:26:48 +1100 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.1/8.14.1) with ESMTP id lABIQlOS034541; Mon, 12 Nov 2007 05:26:47 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.1/8.14.1/Submit) id lABIQlYg034540; Mon, 12 Nov 2007 05:26:47 +1100 (EST) (envelope-from peter) Date: Mon, 12 Nov 2007 05:26:47 +1100 From: Peter Jeremy To: Randall Hyde Message-ID: <20071111182647.GH82929@server.vk2pj.dyndns.org> References: <000701c82253$b3a8c030$6302a8c0@pentiv> <20071108225238.GB22005@dan.emsphone.com> <4734061D.9000606@freebsd.org> <002701c8248b$9c2b8110$6302a8c0@pentiv> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xQmOcGOVkeO43v2v" Content-Disposition: inline In-Reply-To: <002701c8248b$9c2b8110$6302a8c0@pentiv> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.16 (2007-06-09) Cc: freebsd-hackers@freebsd.org Subject: Re: Some FreeBSD performance Issues X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Nov 2007 09:14:45 -0000 --xQmOcGOVkeO43v2v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 11, 2007 at 09:52:21AM -0800, Randall Hyde wrote: >why C's code was so much faster, I dug into the source code and discovered >that open/read/write/etc. use *buffered* I/O (which explains why "dd" >performs so well). open/read/write/etc. do _not_ do any buffering in userland. This is easily demonstrated using eg $ ktrace dd if=3D/dev/random of=3D/dev/null count=3D50 bs=3D1 The relevant part of the output is: 30532 dd CALL read(0x3,0x2820410c,0x1) 30532 dd GIO fd 3 read 1 byte ")" 30532 dd RET read 1 30532 dd CALL write(0x4,0x2820410c,0x1) 30532 dd GIO fd 4 wrote 1 byte ")" 30532 dd RET write 1 30532 dd CALL read(0x3,0x2820410c,0x1) 30532 dd GIO fd 3 read 1 byte "a" 30532 dd RET read 1 30532 dd CALL write(0x4,0x2820410c,0x1) 30532 dd GIO fd 4 wrote 1 byte "a" 30532 dd RET write 1 >At this point I'm not sure why FreeBSD's API call is so slow You have yet to provide any evidence of this. So far, you can only demonstrate it on your application - which strongly suggests it's a problem with your code, rather than FreeBSD. Have you check the ktrace output from your code or time(1)d it as suggested? --=20 Peter Jeremy Please excuse any delays as the result of my ISP's inability to implement an RFC2821-compliant MTA. --xQmOcGOVkeO43v2v Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFHN0ln/opHv/APuIcRAoAJAJ9GYJCfWp8zsZslEy97oskrh5wXnwCfe4Cy zAvkd65pdt9hpEc9SlnnS48= =uxuo -----END PGP SIGNATURE----- --xQmOcGOVkeO43v2v--