-
Notifications
You must be signed in to change notification settings - Fork 269
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 add-type operations #397
Conversation
5cd0b49
to
35334f7
Compare
Is there any reason to consider doing addRangeClosed backwards, so we could use |
@Dr-Emann that's a cool idea! Just thinking about it offhand, I would say that
Nice idea! Hmm, let me do a dry-run of doing it that way now. I wouldn't want to do it if it makes the code look too ugly, but if the code is still readable, I think it would be reasonable to implement your idea. |
35334f7
to
a8da301
Compare
I've rebased and fixed a couple of snake cases. I think I'll save the suggestion from @Dr-Emann until a future PR. |
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.
Looks good to me!
Can you give me another chance to look over this one? |
In this PR we have a straightforward improvement: simplification and some potential speedup, and I think it's ready to merge. With the technique of #402 the benefits are performance at the cost of some increase in complexity. For that reason, I'd suggest to do that in a separate PR so we can evaluate whether the performance is worth the complexity. Whether in this PR or in another, I'd suggest benchmarking. |
Its your judgment call. I would point out that the way I would do it is pull out the Then both Then, the main bodies of |
I see, that does look much better! If you'd like let's give it a try in this PR. |
a8da301
to
334e27e
Compare
OK, this latest version is how it looks with I also took the liberty of rebasing against the latest Above I said we could remove |
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.
@kosak I agree with you that this is just as readable as before, and likely a performance improvement too. Looks great, just a few nits.
tests/cpp_unit.cpp
Outdated
// For example (assuming num_slots_to_test = 5), we: | ||
// create a Roaring64Map, (do nothing), fill 5 slots, and check | ||
// Then we: | ||
// create a Roaring64Map, set a bit in slot 0, fill 5 slots, and check | ||
// Then we: | ||
// create a Roaring64Map, set a bit in slot 1, fill 5 slots, and check | ||
// Then we: | ||
// create a Roaring64Map, set a bit in slots 0 and 1, fill 5 slots, and check | ||
// etc. |
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.
Nit: This is somewhat hard to read, it would make it easier to read if it was a numbered list:
// For example (assuming num_slots_to_test = 5), we:
// 1. create a Roaring64Map, (do nothing), fill 5 slots, and check
// 2. create a Roaring64Map, set a bit in slot 0, fill 5 slots, and check
...
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.
I rewrote it. Kindly let me know if this explanation reads better?
334e27e
to
3b66926
Compare
Responded to review feedback, and rebased onto latest |
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.
Looks good!
Fixed typo. Please take another look. |
Merging. |
lookupOrCreateInner
to reduce the number of repetitions of thesetCopyOnWrite
call.addRangeClosed
so it is clearer what is going on. Also, for the "middle section", where the method is creating completely full inner Roaring bitmaps, create one "the hard way" and then copy it if you need more. (Note: if there is some more efficient way to create a completely full 32 bit Roaring, please let me know)addMany(size_t, const uint64_t*)
to cache its last outer map lookup and perhaps save a few lookups if there is locality that can be exploited.