Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Apr 2003 13:04:31 -0700
From:      Nate Williams <nate@yogotech.com>
To:        Tom Samplonius <tom@sdf.com>
Cc:        freebsd-java@freebsd.org
Subject:   Re: Is FreeBSD the right platfrom for JBOSS ?
Message-ID:  <16009.61647.371831.725618@emerger.yogotech.com>
In-Reply-To: <Pine.BSF.4.05.10304010848300.3487-100000@misery.sdf.com>
References:  <002501c2f841$86e3e480$9001000a@thorsten4> <Pine.BSF.4.05.10304010848300.3487-100000@misery.sdf.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>   There is a perception that native OS threads are always faster than
> green threads or some other internally implemented thread system.

It turns out that if you're application is CPU and not I/O bound, in
most cases 'green threads' or non-kernel threads will almost always
faster.  (I/O can read/writing logfiles, reading/writing to the console,
etc..)

In fact, even if you're doing network I/O, Java's internal threading
library does a pretty good job of not blocking due to it's use of
select/poll.

However, if you have to read/write files, then the simple threading
model used by FreeBSD (pthreads and/or green-threads) doesn't work well,
because it ends up blocking inside the syscall.

> That isn't always the case. For intstance, Weblogic built their own
> JVM (JRockit) and they purposesly implemented their own thread system
> that does not use OS threads at all.  They claim that their JVM is
> faster for hosting server apps than any other JVM.

That's not suprising at all.  I wrote a network client/server
application in 100% Java that used thousands of threads, and it ran up
to 2 orders of magnitude faster using green-threads vs. native (kernel)
threads on Solaris.

It was a fun problem, and optimizing the solution to work well using
both threading models allowed us to find and fix a number of design
problems where we made some invalid assumptions about how the thread
scheduling would happened.  Live-lock, dead-lock, and races are *very*
common in many Java programs.  The best way to avoid them is to test
your app using the different threading models available.  Besides, it's
good practice for doing SMP work. :) :)



Nate



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16009.61647.371831.725618>