killing lutexes, adding timeouts
authorNikodemus Siivola <nikodemus@random-state.net>
Tue, 16 Aug 2011 19:46:06 +0000 (22:46 +0300)
committerNikodemus Siivola <nikodemus@random-state.net>
Wed, 9 Nov 2011 23:00:48 +0000 (01:00 +0200)
commitd6f9676ae94419cb5544c45821a8d31adbc1fbe8
tree932dc55b09fd3506edba5728a29811db3c99020d
parentecfd159f29d31d2cc08d4e5598346c04c9387636
killing lutexes, adding timeouts

  * Remove all lutex-specific code from the system.
    ** Use SB-FUTEX for futex-capable platforms, and plain SB-THREAD
       otherwise.
    ** Make non-futex mutexes unfair spinlocks for now, using WAIT-FOR to
       provide timeouts and backoff.
    ** Build non-futex condition variables on top of a queue and WAIT-FOR.

    Performance implications: SB-FUTEX builds should perform pretty much the
    same, or improve a bit. Threaded non-futex builds are affected as follows:

      1. Threads idling on semaphores or condition variables aren't quite as
         cheap. Just how costly depends on the OS. On Darwin 1000 idle threads
         can chew up a bit over 50% CPU. I will try to address this later.

      2. Contested locking around operations that take considerably longer
         than a single timeslice suffers mild degradation.

      3. Contested locking around operations that don't take long is an order
         of magnitude performant.

      4. Highly active semaphores perform much better. (Follows from #3.)

  * GRAB-MUTEX gets timeout support on all platforms.

  * CONDITION-WAIT gets timeout support.

  * Disable a bunch of prone-to-hang thread tests on Darwin.  (All of them
    were already prone to hang prior to this commit.)

  * Enable a bunch tests that now /pass/ on Darwin. \o/ This doesn't mean that
    the threaded Darwin is fully expected to pass all tests yet, but let's say
    it's more likely to do so.

    ...but still not robust enough to enable threads on Darwin by default.

  * GET-MUTEX/GRAB-MUTEX get refactored into two main parts: %TRY-MUTEX and
    %WAIT-ON-MUTEX, which are also used directly from CONDITION-WAIT where
    appropriate.
30 files changed:
base-target-features.lisp-expr
contrib/sb-introspect/introspect.lisp
make-config.sh
package-data-list.lisp-expr
src/code/cross-thread.lisp
src/code/deadline.lisp
src/code/gc.lisp
src/code/late-extensions.lisp
src/code/pred.lisp
src/code/primordial-extensions.lisp
src/code/target-thread.lisp
src/code/thread.lisp
src/compiler/generic/early-objdef.lisp
src/compiler/generic/genesis.lisp
src/compiler/generic/late-type-vops.lisp
src/compiler/generic/objdef.lisp
src/compiler/generic/vm-fndb.lisp
src/runtime/GNUmakefile
src/runtime/coreparse.c
src/runtime/gencgc.c
src/runtime/gencgc.h
src/runtime/pthread-lutex.c [deleted file]
src/runtime/pthread-lutex.h [deleted file]
src/runtime/purify.c
src/runtime/save.c
tests/deadline.impure.lisp
tests/debug.impure.lisp
tests/test-util.lisp
tests/threads.impure.lisp
tests/threads.pure.lisp