Is FreeBSD the right platfrom for JBOSS ?

Nate Williams nate at yogotech.com
Tue Apr 1 12:04:44 PST 2003


>   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


More information about the freebsd-java mailing list