GLib: implement GMutex natively on Linux
authorRyan Lortie <desrt@desrt.ca>
Tue, 10 Jun 2014 12:28:32 +0000 (08:28 -0400)
committerRyan Lortie <desrt@desrt.ca>
Wed, 9 Jul 2014 14:59:06 +0000 (10:59 -0400)
commit49b59e5ac4428a6a99a85d699c3662f96efc4e9d
treeb74568be714605de324207d6d6f298321a352b2e
parentbe0b921115c319186c678a054958f405b8c90a2b
GLib: implement GMutex natively on Linux

If we have futex(2) then we can implement GMutex natively and gain a
substantial performance increase (vs. using pthreads).

This also avoids the need to allocate an extra structure in memory when
using GMutex or GCond: we can use the structure directly.

The main reason for the increase in performance is that our
implementation can be made more simple: we don't need to support the
array of options on pthread_mutex_t (which includes the possibility, for
example, of being recursive).

The result is a ~30% improvement in uncontended cases and a much larger
increase (3 to 4 times) in contended cases for a simple testcase.

https://bugzilla.gnome.org/show_bug.cgi?id=731986
glib/gthread-posix.c