Skip to content

Conversation

@laborg
Copy link
Contributor

@laborg laborg commented Dec 25, 2024

We only need to remove one element from a ChainedVector and can therefore special case the fact that if this element is a single entry in a chunk the chunk can be removed completely. This reliefs us from the slow cleanup!() call.
As a result dependent functions performance improve:

pop!() with many chunks

julia> function popall(x)
           while length(x) >0
               pop!(x)
           end
       end
popall (generic function with 1 method)

julia> popall(ChainedVector([[1]])); # compilation

julia> cv = ChainedVector([rand(Int,5) for _ in 1:20000]);

julia> @time popall(cv) # main
  1.043174 seconds

julia> @time popall(cv) # pr
  0.003701 seconds

popfirst!() with many chunks

julia> function popall(x)
           while length(x) >0
               popfirst!(x)
           end
       end
popall (generic function with 1 method)

julia> popall(ChainedVector([[1]])); # compilation

julia> cv = ChainedVector([rand(Int,5) for _ in 1:20000]);

julia> @time popall(cv) # main
  1.423213 seconds

julia> @time popall(cv) # pr
  0.128358 seconds 

popfirst!() with single chunk

julia> function popall(x)
           while length(x) >0
               popfirst!(x)
           end
       end
popall (generic function with 1 method)

julia> popall(ChainedVector([[1]])); # compilation

julia> cv = ChainedVector([rand(Int,100000)]);

julia> @time popall(cv)
  0.002024 seconds # main

julia> @time popall(cv)
  0.001135 seconds # pr

We only need to remove one element from a ChainedVector and can therefore special case the fact that if this element is a single entry in a chunk the chunk can be removed completely. This reliefs us from the slow `cleanup!()` call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant