On Thu, 30 Nov 2000, Arnaud Installe wrote:
> On Thu, Nov 30, 2000 at 08:47:49AM -0600, Ray Bryant wrote:
> > The IBM implementations of the Java language use native threads --
> > the result is that every time you do a Java thread creation, you
> > end up with a new cloned process.  Now this should be pretty fast,
> 
> Well, I think the problem is that it is *too* fast.  :-/  What I think
> happens is that a lot of threads get created at the same time, and they
> all run a bit of initialization code.  This way a lot of processes are in
> the running state, so that the load average gets *very* high, which makes
> the system very unresponsive.

Certainly sounds plausible; if the first process is able to create a lot of
runnable processes/threads in a single timeslice, the scheduler is then hit
with a huge queue to plough through once that timeslice ends.

Making calls to clone() force a schedule() might help here? That way, hopefully
each thread can run its initialisation code before the next one is created,
avoiding the problem?

> Could this be correct ?  Also, I haven't seen this happen with NT.  Could
> it be that Java on NT uses user-mode threading and creates threads much
> more slowly, resulting in a lower load ?

Perhaps; alternatively, if it schedules the new thread to run before resuming
the parent thread, each thread is initialised when created, rather than
building up a huge backlog, that would avoid the problem.

> > so I am surprised that it stalls like that.  It is possible this
> > is a scheduler effect.  Do you have a program example you can
> > share with us?
> 
> So I suppose it is a scheduler effect.  Can this be solved on the kernel
> side (a /proc/sys setting perhaps ?), or should a check be built-in into
> the software that no more than a certain number of threads are created per
> time unit ?

Either of those could help. Alternatively, have you tried inserting a yield
instruction in the Java code after creating each thread, to make sure the new
thread gets a chance to initialise?


James.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to