Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
Use a global search lower bound.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Oct 25, 2019
1 parent 39d82ba commit dff6d0d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/memory/split.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit dff6d0d

Please sign in to comment.