[wanproxy/wanproxy] 8dee0b: Improve performance of mutexes.

Juli Mallett juli at clockworksquid.com
Sun Apr 19 19:32:34 PDT 2015


  Branch: refs/heads/master
  Home:   https://github.com/wanproxy/wanproxy
  Commit: 8dee0b1d3cca5067d988d4f648d57fb5e0f9510d
      https://github.com/wanproxy/wanproxy/commit/8dee0b1d3cca5067d988d4f648d57fb5e0f9510d
  Author: Juli Mallett <juli at clockworksquid.com>
  Date:   2015-04-19 (Sun, 19 Apr 2015)

  Changed paths:
    M common/thread/lock.h
    M common/thread/mutex_posix.cc
    M common/thread/mutex_posix.h
    M common/thread/sleep_queue_posix.cc

  Log Message:
  -----------
  Improve performance of mutexes.

- Have try_lock() itself only try to acquire the state lock to
  avoid getting involved in nasty churning trying to acquire the
  state lock.

- Add some assertions to ScopedLock to catch deadlocks due to
  recursion.

- Use a FIFO waiter system rather than first past the post.

- Related to the FIFO waiters, ensure that we broadcast the wakeup
  signal, so that we don't wake up a single waiter which fails to
  take the lock.

These changes vastly improve performance and stability with very
mutex-heavy workloads with a lot of contention.




More information about the wanproxy mailing list