This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: GC and Linux/SPARC?
- To: Tom Tromey <tromey at cygnus dot com>
- Subject: Re: GC and Linux/SPARC?
- From: Jeff Sturm <jsturm at sigma6 dot com>
- Date: Fri, 12 Nov 1999 06:10:33 -0500 (EST)
- cc: Jeff Sturm <jsturm at sigma6 dot com>, Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>, Bryce McKinlay <bryce at albatross dot co dot nz>, java-discuss at sourceware dot cygnus dot com
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