Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of sizehint! on BinaryHeap #907

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

Tortar
Copy link
Contributor

@Tortar Tortar commented Apr 17, 2024

Noticed that sizehint! was actually worsening a lot of the performance of some of my heaps, with this change it is much faster:

e.g. with

using DataStructures, BenchmarkTools
function with_sizehint(T, n)
    value = BinaryHeap(Base.Order.ForwardOrdering(), T[])
    sizehint!(value, n)
end

before:

julia> @btime with_sizehint(Int, 1);
  861.250 ns (5 allocations: 256 bytes)

after:

julia> @btime with_sizehint(Int, 1);
  64.790 ns (4 allocations: 224 bytes)

@Tortar
Copy link
Contributor Author

Tortar commented Apr 17, 2024

Oh actually 1.6 doesn't support @inline at callsite, so I will inline it in the definition

@oxinabox oxinabox merged commit 90e955b into JuliaCollections:master Apr 18, 2024
10 checks passed
@oxinabox
Copy link
Member

oxinabox commented Apr 18, 2024

Great, I have back ported this also to 0.18.20
should be available in 10 minutes or so

@Tortar Tortar deleted the patch-1 branch April 18, 2024 08:36
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.

None yet

2 participants