From owner-freebsd-hackers Mon Mar 19 12: 6:12 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 9317837B71D for ; Mon, 19 Mar 2001 12:06:03 -0800 (PST) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f2JK62x06552; Mon, 19 Mar 2001 12:06:02 -0800 (PST) Date: Mon, 19 Mar 2001 12:06:02 -0800 From: Alfred Perlstein To: Thierry Herbelot Cc: hackers@FreeBSD.ORG Subject: Re: scheduling frequency for threaded applications ? Message-ID: <20010319120601.A29888@fw.wintelcom.net> References: <3AB66167.7DE93AB2@herbelot.com> <20010319114625.Z29888@fw.wintelcom.net> <3AB664FE.32CD18CD@herbelot.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3AB664FE.32CD18CD@herbelot.com>; from thierry@herbelot.com on Mon, Mar 19, 2001 at 08:58:54PM +0100 X-all-your-base: are belong to us. Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Thierry Herbelot [010319 11:59] wrote: > Alfred Perlstein wrote: > > > > * Thierry Herbelot [010319 11:43] wrote: > > > Hello, > > > > > > I'm developping a network benchmark application ("packet blaster"). > > > > > > The current version uses many processes, to send and receive packets, > > > and collate statistics. > > > when I look at top(1), I see most of the time taken is in the "system" > > > category. I assume this is due to the many context switches between the > > > collaborating processes. > > > > You're incorrect. System means just about any time spent inside the > > kernel (except interrupts), so basically syscalls count towards this > > meaning that your application is driving the kernel pretty hard. > > > > This is easy for a team of processes, but nearly impossible with > > a thread based approach. > > could you please elaborate ? (indeed, if you could also shed some light > on the first question : how frequently are threads rescheduled ?) I really have no idea how frequently threads are rescheduled. the point is this: In FreeBSD a threaded application has a single process context, meaning that the kernel schedules all threads as a single entity. In effect you limit the parallelness(?) by using threads. Now if you want kernel threads, then use the linux-threads port, however you're back to normal process scheduling because afaik linux-threads (at least when run on FreeBSD) are implemented with processes. I don't think you understand that the overhead you're seeing is most likely _not_ because of any scheduler issue, but more likely because you're asking the kernel to do a signifigant amount of work for you. This is about as far as I'm going to go on the issue, basically once you make your "write()" syscall, you enter into 'system' time because you're having the kernel do work for you. The getrusage() manpage might be a good place to look for more answers. > PS : the TI-RPC commit was a nice one ! There's still a few kinks to work out, hope to have it fixed within the next couple of days. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message