GC and Linux/SPARC?

Jeff Sturm jsturm@sigma6.com
Fri Nov 12 03:09:00 GMT 1999


On 1999年11月11日, 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


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /