From owner-freebsd-emulation Tue Jan 4 16: 3:52 2000 Delivered-To: freebsd-emulation@freebsd.org Received: from ns.mt.sri.com (ns.mt.sri.com [206.127.79.91]) by hub.freebsd.org (Postfix) with ESMTP id 7C3B414D5E for ; Tue, 4 Jan 2000 16:03:41 -0800 (PST) (envelope-from nate@mt.sri.com) Received: from mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by ns.mt.sri.com (8.9.3/8.9.3) with SMTP id RAA15851; Tue, 4 Jan 2000 17:03:34 -0700 (MST) (envelope-from nate@rocky.mt.sri.com) Received: by mt.sri.com (SMI-8.6/SMI-SVR4) id RAA15774; Tue, 4 Jan 2000 17:03:33 -0700 Date: Tue, 4 Jan 2000 17:03:33 -0700 Message-Id: <200001050003.RAA15774@mt.sri.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: "Richard Seaman, Jr." Cc: Nate Williams , Amancio Hasty , Bob Shaw , emulation@FreeBSD.ORG Subject: Re: linux_base-6.1: Are Linux threads supported? In-Reply-To: <20000104162325.C15887@tar.com> References: <200001041947.MAA14347@mt.sri.com> <200001042127.NAA25824@rah.star-gate.com> <200001042135.OAA15019@mt.sri.com> <20000104162325.C15887@tar.com> X-Mailer: VM 6.34 under 19.16 "Lille" XEmacs Lucid Reply-To: nate@mt.sri.com (Nate Williams) Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > Linux kernel threads are not native kernel threads. They are not part > > of the standard distribution, they have an incompatible license, and do > > not scale very well on most Java applications. However, for *certain* > > applications they do work, but these are limited to mostly CPU-bound > > applications that do light I/O. Applications that have lots of I/O > > threads will not work well with the Linux-threads stuff. (While > > applications run with the green-threads version tends to work *very* > > well, almost as well as C code.) > > I'm confused by all this. No need to be confused. :) > For more than a year the FreeBSD linuxulator has had a functioning > "clone()" syscall. AFAIK it works fine with the libpthread that ships > with recent versions of linux, as long as its used with a compatible > version of linux glibc. So far so good. Again, this isn't 'native' though, as I pointed out in an earlier email. > If you want SMP threads in the linuxulator, you need to be running > FreeBSD-current. If you're UP, then AFAIK any version of 3.X since > about last April or May is ok. Right, this gives you the 1:1 user/kernel thread mapping. > I don't understand why I/O threads would not work well with > linuxthreads. They work fine, but tend to be too heavy when the number of active I/O threads gets large. Too many threads are spawned off, taking up too many resources and the system tends to bog down heavily. On my system, I had roughly 2000 running threads, with about 50-100 of them active at any one point. About 2/3 of them were involved in I/O of some kind, and as such would become 'kernel threads' in the kernel thread implementation. Using the green-thread implementation of the Java VM, context switches were very fast, and the use of select inside the green-thread libraries caused the application to rarely block inside the kernel. (Although, at times it did block, especially when writing to disk.) > Programs like squid work very well with linuxthreads, and AFAIK will > outperform squid compiled with FreeBSD "user" threads. "kernel > threads" should improve This is sometimes the case, but not always. In my case, the number of threads and their weight caused the program to behave very *poorly*, because it took so many more resources. The 'userland thread' implementation (using select behind the scenes) performed much better than the 'kernel thread' version. > I/O concurrency when there is I/O that blocks in the kernel. In my case, most of the time the I/O didn't block in the kernel because select was used. Keeping things 'lightweight' made it much easier to do context switching, and the number of resources used was much less. So, I state again the existing 'non-native' kernel thread implementation is not always a win. It depends on your application. > Each linuxthreads context switch involves a syscall. If you have a threads > implemenation that can do some context switches without making a syscall > (should be very doable, but FreeBSD user threads isn't there at this point), > then those context switches should be *much* faster than linuxthreads, > because a syscall is so expensive. I have to assume that the "green-threads" > you are referring to are different than FreeBSD user threads. They are similar to the user-land threads code that exist in FreeBSD, but are tuned specifically to the JVM. They are in fact part of the JDK implementation. However, like the existing userland threads code, they block inside of the kernel, since they have no concept of 'kernel threads'. Finally, they are not 'publically' available, so we couldn't use them even if we wanted to. The other choice in the JDK is to use 'native' kernel threads, but the existing 'kernel threads' in FreeBSD has some negative side-effects which you just spoke about. So, in summary, the Linux JDK that uses native threads is not necessarily a win because of it's use of native threads. As a matter of fact, it may be a loss, due to the architectural side-effects of the existing linux threads implementation. Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message