-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 some IntSet operations #23138
Conversation
* IntSet has a new invariant: the length of the underlying BitArray is always a multiple of 64 * the size is set to the minimum possible: the underlying routines are in charge of allocating enough (like for other containers); this can help to obtain the last element faster (which is useful e.g in `rand(::IntSet)`) * _matched_map avoids extending a BitArray when unecessary (but doesn't work anymore for all 2^4 kinds of binary predicate, though it could be handled if needed in the future)
end | ||
b | ||
end | ||
@inline in(n::Integer, s::IntSet) = get(s.bits, n, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change, but simpler.
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
stockcorr and array indexing regressions have a chance of being real, should keep an eye on the nightly results |
Given ae17198#commitcomment-23501641 it might be worth looking into the array indexing regression? |
Looking at the very few places in base where |
doesn't inference use them in some key places? otherwise they'd likely be moved out to DataStructures |
Inference uses them, but I thought it wouldn't influence the run time performance and the benchmarks. |
Now IntSet have the length of their underlying BitVector be a multiple of 64, so resizing them to something else breaks this invariant.
fix IntSet tests invalid since #23138
is always a multiple of 64
are in charge of allocating enough (like for other containers);
this can help to obtain the last element faster (which is useful
e.g in
rand(::IntSet)
)(but doesn't work anymore for all 2^4 kinds of binary predicate,
though it could be handled if needed in the future)
A case where this could be slower is for example in:
But I could not really/reliably measure a difference (disclaimer:
BenchmarkTools
is broken recently on my installation, so I use a hand-made "equivalent"), andsizehint!
can help here. The improvements for some operations can be huge, e.g.symdiff!(a, b)
wherea=IntSet([2^20]), b=IntSet([1])
decreases from 45.07µs to 10ns. Also, something likerand(s)
wheres=IntSet([1, 2, 3])
decreases from about 980ns to 310ns.