apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pane <bp...@pacbell.net>
Subject Re: proposed change to reduce nonblocking socket performance overhead
Date Sun, 16 Dec 2001 05:19:44 GMT
Jeff Trawick wrote:

>Brian Pane <bpane@pacbell.net> writes:
>
>>The logic for setting the nonblocking state looks like
>>this:
>>
>>  - fcntl(sd, F_GETFL, ...) to get the current flags on
>>    the socket descriptor
>>  - OR the flags with O_NONBLOCK or O_NDELAY or O_FNDELAY,
>>    depending on the OS.
>>  - fcntl(sd, F_SETFL, flags) to set the new flags.
>>
>>According to the profiler data, the F_GETFL fcntl operation
>>is more expensive than the F_SETFL one.
>>
>
>Dumb question...  Have you tried commenting out the F_GETFL to see
>what happens?  Does the F_SETFL suddenly get more expensive?
>
>What I wonder about is if there is some stream operation that has to
>be performed on one of these first socket calls such that if you
>remove F_GETFL it just makes the next call more expensive.
>

I finally had a chance to look into this just now, but in the
latest round of profiling the F_GETFL operation accounts for
only 7% of the run time of sononblock(), with F_SETFL comprising
the other 93%.  Not coincidentally, the test machine has been
updated with dozens of Solaris 8 patches since the last round
of tests.  As far as I can tell, a function called _so_getsockopt()
in libsocket.so, which is called internally during fcntl(F_GETFL),
seems to have gotten faster in one of these patches (possibly
patch 111327-03).

Thus there's probably no longer a need to optimize away the
F_GETFL for Solaris.

The biggest remaining problem in sononblock() is that fcntl
on Solaris calls fstat64 to figure out if its argument is a
socket, and fstat64 takes a while.

--Brian



Mime
View raw message