Fix long spinning in rtree_node_init
rtree_node_init spinlocks the node, allocates, and then sets the node. This is under heavy contention at the top of the tree if many threads start to allocate at the same time. Instead, take a per-rtree sleeping mutex to reduce spinning. Tested both pthreads and osx OSSpinLock, and both reduce spinning adequately Previous benchmark time: ./ttest1 500 100 ~15s New benchmark time: ./ttest1 500 100 .57s
This commit is contained in:
@@ -13,8 +13,10 @@ rtree_node_alloc_intercept(tsdn_t *tsdn, rtree_t *rtree, size_t nelms)
|
||||
if (rtree != test_rtree)
|
||||
return rtree_node_alloc_orig(tsdn, rtree, nelms);
|
||||
|
||||
malloc_mutex_unlock(tsdn, &rtree->init_lock);
|
||||
node = (rtree_elm_t *)calloc(nelms, sizeof(rtree_elm_t));
|
||||
assert_ptr_not_null(node, "Unexpected calloc() failure");
|
||||
malloc_mutex_lock(tsdn, &rtree->init_lock);
|
||||
|
||||
return (node);
|
||||
}
|
||||
|
Reference in New Issue
Block a user