From dff6d0d64e13834981d139d912f301fd311759ff Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 1 Oct 2019 14:19:38 +0200 Subject: [PATCH] Use a global search lower bound. --- src/memory/split.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/memory/split.jl b/src/memory/split.jl index 9af46651..f6e58e20 100644 --- a/src/memory/split.jl +++ b/src/memory/split.jl @@ -149,6 +149,7 @@ end using Base.Threads: SpinLock const pool_lock = SpinLock() # protect against deletion from freelists +const scan_lower_bound = Block(nothing, 0; id=0) function scan!(blocks, sz, max_overhead=typemax(Int)) max_sz = max(sz + max_overhead, max_overhead) # protect against overflow @lock pool_lock begin @@ -162,8 +163,8 @@ function scan!(blocks, sz, max_overhead=typemax(Int)) # but since we know the sorted set is backed by a balanced tree, we can do better # get the entry right before first sufficiently large one - lower_bound = Block(nothing, sz; id=0) - i, exact = findkey(blocks.bt, lower_bound) + scan_lower_bound.sz = sz # prevent allocations + i, exact = findkey(blocks.bt, scan_lower_bound) @assert !exact # block id bits are zero, so this match can't be exact if i == DataStructures.endloc(blocks.bt)