Some FreeBSD performance Issues

Randall Hyde randyhyde at earthlink.net
Mon Nov 12 08:17:55 PST 2007


>
>
> 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



More information about the freebsd-hackers mailing list