This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GC and Linux/SPARC?




On Thu, 11 Nov 1999, Tom Tromey wrote:
> I seem to remember that our Linux performance problems on SMP were
> because mutexes used spin locks?  Maybe just using a mutex would be ok
> on Linux?

The pthread_mutex_lock on Linux (glibc2.1) uses testandset, but
calls sched_yield() after each unsuccessful attempt to acquire the
spinlock.  That's fine for uniprocessors, but on SMP results in
unnecessary system calls (sched_yield becomes a no-op if no process is
waiting for a CPU).  In other words, pthreads on Linux are not currently
tuned for SMP.

Hand-coded spin locks are generally faster than a pthread mutex for short
durations, like the allocator in boehm-gc.  I posted some numbers a while
ago that demonstrate a 2:1 improvement using spinlocks on Linux.  But the
performance benefit is minor compared to the inconvenience of having to
port boehm-gc to unsupported architectures (i.e. get the code working
first, make it fast later).  I would seem that a mutex is a good
fallback on platforms where GC_test_and_set isn't available.

Jeff



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]