From owner-freebsd-hackers Wed Jan 17 13:10: 6 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from harmony.village.org (rover.village.org [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id 0DA2937B6A8 for ; Wed, 17 Jan 2001 13:09:41 -0800 (PST) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.11.1/8.11.1) with ESMTP id f0HL9Ys40809; Wed, 17 Jan 2001 14:09:36 -0700 (MST) (envelope-from imp@harmony.village.org) Message-Id: <200101172109.f0HL9Ys40809@harmony.village.org> To: Trent Nelson Subject: Re: Network I/O multiplexing questions. Cc: freebsd-hackers@FreeBSD.ORG In-reply-to: Your message of "Wed, 17 Jan 2001 14:23:43 EST." <20010117142343.A1144@dhcp103-172-16-3.switch.com> References: <20010117142343.A1144@dhcp103-172-16-3.switch.com> Date: Wed, 17 Jan 2001 14:09:34 -0700 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <20010117142343.A1144@dhcp103-172-16-3.switch.com> Trent Nelson writes: : 1. Is there any performance/efficiency gained when read and write : operations on multiple sockets are grouped together? That is, after : the I/O multiplexer function returns (i.e. select/poll/kevent), all : read operations on sockets are done together (say, encapsulated by : a thread, perhaps) and likewise for write operations. No. Not really. If the sockets are non-blocking, then doing a read is a fast operation. It will either return EWOULDBLOCK (in case something odd happened between the select and the read), or it will do a copyout of what data is there. You'd gain nothing by doing multiple of these at once. Likewise with nonblocking writes. It will either copy it in and return, or it will return EWOULDBLOCK. I've never hit scalibility problems in this area of the code. But I've also never tried to optimize things on a MP box in this area. That's the only way that having multiple outstanding read/writes makes any kind of performance sense. : 3. What conditions, if any, are used to deem whether a read or write : to a socket will block? Is there any quick and efficient way of : doing this in userspace? I'm assuming it has something to do with : the hi/lo watermarks of a socket and its associated I/O buffer. : : Can anyone point me to instances of kernel source code where a check : is made to see if a socket will block? select(), et al, will tell you if the woudl block. Make them non-blocking and you don't even have to worry about that. You get EWOULDBLOCK back from them. I can't point you at the source, however. For blocking sockets, reads block when there is no data and the connection is still good. Writes block when there's no kernel buffer space available for that socket. : 4. Currently, if a process blocks on network I/O, is it immediately : switched out of execution by the scheduler? Yes. Blocking is blocking. You can't run if you are blocked. That's why pthreads makes all its stuff non-blocking. : 5. Has anyone taken a look at the State-Threads API proposed by SGI? Nope. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message