diff options
author | Jason Evans <jasone@canonware.com> | 2016-10-13 21:47:50 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-10-13 21:55:39 (GMT) |
commit | e5effef428b5bf941e1697f6000c97f1ce734756 (patch) | |
tree | c47df293e2107ae293644fa922876224c235c527 /src/rtree.c | |
parent | 9acd5cf178eca9bc8a7f36a8c392b799a120bcbf (diff) | |
download | jemalloc-e5effef428b5bf941e1697f6000c97f1ce734756.zip jemalloc-e5effef428b5bf941e1697f6000c97f1ce734756.tar.gz jemalloc-e5effef428b5bf941e1697f6000c97f1ce734756.tar.bz2 |
Add/use adaptive spinning.
Add spin_t and spin_{init,adaptive}(), which provide a simple
abstraction for adaptive spinning.
Adaptively spin during busy waits in bootstrapping and rtree node
initialization.
Diffstat (limited to 'src/rtree.c')
-rw-r--r-- | src/rtree.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rtree.c b/src/rtree.c index 421de3e..d4a705a 100644 --- a/src/rtree.c +++ b/src/rtree.c @@ -136,12 +136,15 @@ rtree_node_init(tsdn_t *tsdn, rtree_t *rtree, unsigned level, rtree_elm_t *node; if (atomic_cas_p((void **)elmp, NULL, RTREE_NODE_INITIALIZING)) { + spin_t spinner; + /* * Another thread is already in the process of initializing. * Spin-wait until initialization is complete. */ + spin_init(&spinner); do { - CPU_SPINWAIT; + spin_adaptive(&spinner); node = atomic_read_p((void **)elmp); } while (node == RTREE_NODE_INITIALIZING); } else { |