From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 12 16:17:55 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 5B0ED16A41A for ; Mon, 12 Nov 2007 16:17:55 +0000 (UTC) (envelope-from randyhyde@earthlink.net) Received: from elasmtp-kukur.atl.sa.earthlink.net (elasmtp-kukur.atl.sa.earthlink.net [209.86.89.65]) by mx1.freebsd.org (Postfix) with ESMTP id 2E7A313C48A for ; Mon, 12 Nov 2007 16:17:55 +0000 (UTC) (envelope-from randyhyde@earthlink.net) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=earthlink.net; b=C/3b1q4LelNJBLFJqWx6azBE9cOvIGBnX86S6bqCnK3R68lI9Kcil7MccpP+N0Ly; h=Received:Message-ID:From:To:References:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Priority:X-MSMail-Priority:X-Mailer:X-MimeOLE:X-ELNK-Trace:X-Originating-IP; Received: from [66.215.252.78] (helo=pentiv) by elasmtp-kukur.atl.sa.earthlink.net with asmtp (Exim 4.34) id 1Irbyq-0007xy-Q4 for freebsd-hackers@freebsd.org; Mon, 12 Nov 2007 11:17:44 -0500 Message-ID: <002e01c82547$8e8c6350$6302a8c0@pentiv> From: "Randall Hyde" To: References: <000701c82253$b3a8c030$6302a8c0@pentiv> <47384B75.5090806@maxlor.com> Date: Mon, 12 Nov 2007 08:17:43 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 X-ELNK-Trace: eba5e0c9192a36dcd6dd28457998182d7e972de0d01da940127837ef19c704834cef22ed9f6b61f5350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 66.215.252.78 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 16:17:55 -0000 > > > Hello Randy, > > First, let me out myself as a fan of yours. It was your book that got me > started on ASM and taught me a lot about computers and logic, plus it > provided some entertainment and mental sustenance in pretty boring > times, so thanks! > > Now, as for your problem: I think I have to agree with the others in > this thread when they say that the problem likely isn't in FreeBSD. The > following C program, which uses the read(2) call to read socket.h > byte-by-byte, runs quickly (0.05 secs on my 2.1GHz system, measured with > time(1)): > << code snipped>> > > This should be quite equivalent to your second and third code fragment; > it does one read system call per byte, no buffering involved. This leads > me to believe that the slowdown occurs in your fileio.read wrapper, or > maybe in the process setup/teardown process. Actually, I'd already gone that route. Looking at the wrong copy of read.c (in the libstd directory) is what had me convinced of the buffering issue. However, the code you posted is still going through libc, so I'm not ready to trust that. However, I just used the syscall system call to make the same INT $80 calls from C that I'm making from the assembly code and that seems to work okay. I've disassembled the code for both programs (my assembly code and the C code that's making direct system calls) and for the life of me, I can't (yet) see any reason why the C code would run two orders of magnitude faster. I guess I'm going to have to look at the start-up code used by the C run-time system and see if it is doing something funny. Note to others: still haven't done ktrace, through looking at the object code for the two programs it's hard to believe that there would be extra system calls taking place or anything like that. If I had to guess at this point, I'd say that my calls are blocking a lot longer than the C program's. My user and system times are low, but real time is very high. Still haven't done ktrace. I'll try that when I get back into town later this week. Cheers, Randy Hyde