[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <462D2177.1060609@amhost.net>
Date: Tue, 24 Apr 2007 00:13:27 +0300
From: voron <voron@...ost.net>
To: linux-kernel@...r.kernel.org
Subject: sendfile to nonblocking socket
Hello
I'm testing a web server nginx for films sharing in my LAN. And I've got
some interesting results. When I tried to download film or another big
file via gigabit link, I've got sendfile block with nonblocking
socket. Strace log in attach. Some commens
#enabling nonblock on fd 3
20:51:20 ioctl(3, FIONBIO, [1]) = 0
#normal nonblocking sendfile, asked 2147480274 bytes, sent 236164
bytes, so nonblocking works
20:51:20 sendfile(3, 8, [847150], 2147480274) = 236164
#sendfile 390 M, 6 seconds
20:51:22 sendfile(3, 8, [102578266], 2147481510) = 390115144
#sendfile 1000 M, 15 seconds
20:51:40 sendfile(3, 8, [1303409692], 2147482596) = 1008100764
#sendfile ~2G, 30 seconds
20:51:55 sendfile(3, 8, [2312288408], 1982678888) = 1982678888
As I see, nonblocking mode is enabled - sendfile sends less than asked.
But 2G via single 30 seconds sendfile call - this is blocking call. How
can I avoid that? I prefer sendfile as fastest way to send file
content to network socket. The problem with sendfile block on
nonblocking socket has place only when I'm using network connection,
that is faster than my hard disk, for example gigabit NIC or localhost.
When I use 100Mbit NIC, which is slower, than my hard disk, I got small
and fast sendfile calls without blocking.
My kernel is Linux 2.6.20.3-grsec x86_64. I verified that also on
2.6.18 - same results. Please advise.
ps: I've did same tests with lighttpd's sendfile and got same results -
block on nonblocking socket, when network is faster than disk.
Thank you,
Alex
View attachment "strace.log" of type "text/plain" (5129 bytes)
Powered by blists - more mailing lists