Skip to content
  • Allison Karlitskaya's avatar
    GLib: implement GMutex natively on Linux · 49b59e5a
    Allison Karlitskaya authored
    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
    49b59e5a