From owner-freebsd-net@FreeBSD.ORG Thu Oct 21 05:37:11 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2534A16A4CE for ; Thu, 21 Oct 2004 05:37:11 +0000 (GMT) Received: from park.rambler.ru (park.rambler.ru [81.19.64.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id BACF443D31 for ; Thu, 21 Oct 2004 05:37:09 +0000 (GMT) (envelope-from is@rambler-co.ru) Received: from is.park.rambler.ru (is.park.rambler.ru [81.19.64.102]) by park.rambler.ru (8.12.6/8.12.6) with ESMTP id i9L5b7is090711; Thu, 21 Oct 2004 09:37:07 +0400 (MSD) (envelope-from is@rambler-co.ru) Date: Thu, 21 Oct 2004 09:37:07 +0400 (MSD) From: Igor Sysoev X-X-Sender: is@is.park.rambler.ru To: "Ronald F. Guilmette" In-Reply-To: <79296.1098306696@monkeys.com> Message-ID: <20041021091935.K17688@is.park.rambler.ru> References: <79296.1098306696@monkeys.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@freebsd.org Subject: Re: aio_connect ? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2004 05:37:11 -0000 On Wed, 20 Oct 2004, Ronald F. Guilmette wrote: > > and they require too many syscalls. > >E.g, the reading requires > >*) 3 syscalls for ready data: aio_read(), aio_error(), aio_return() > >*) 5 syscalls for non-ready data: aio_read(), aio_error(), > > waiting for notification, then aio_error(), aio_return(), > > or if timeout occuired - aio_cancel(), aio_error(). > > This assumes that one is _not_ using the signaling capabilities of the > aio_*() functions in order to allow the kernel to dynamically signal the > userland program upon completion of a previously scheduled async I/O > operation. If however a programmer were to use _that_ approache to de- > tecting I/O completions, then the number of syscals would be reduced > accordingly. Yes, nginx does not use the AIO signaling capabilities. With signals you do not call the syscall that waits the completion. But the call of the signal handler requires 3 context switches instead of 2 switches in the case of syscall. > However this all misses the point. As I noted earlier in this thread, > efficience _for the machines_ is not always one's highest engineering > design goal. If I have a choice between building a more maintainable, > more adaptable, more modularized program, or instead building a more > machine-efficient program, I personally will almost always choose to > build the clearly, more modularized program as opposed to trying to > squeeze every last machine cycle out of the thing. In fact, that is > why I program almost exclusively in higher level languages, even though > I could almost certainly write assembly code that would almost always be > faster. Machine time is worth something, but my time is worth more. I believe if you want to build a more maintainable, more adaptable, more modularized program then you should avoid two things - the threads and the signals. If you like to use a callback behaviour of the signals you could easy implement it without any signal. Igor Sysoev http://sysoev.ru/en/