-
Notifications
You must be signed in to change notification settings - Fork 12.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
Add bit removal methods to SparseBitMatrix and factor *BitSet relational methods into more extensible trait #88272
Conversation
Is there anything you could need beyond |
I could implement those methods, although they would still end up calling fn row_mut(&mut self, row: R) -> Option<&mut HybridBitSet<C>>; This eliminates the weird side effect, and also matches the existing API. But if you have any preference towards lifting the set methods to matrix, I can do that instead. |
My whole point is that they would not call |
Ah I understand, I can do that. One other question. For operations like |
Yes, I think that's the right path, although it means handling all combinations in You probably know this, but an in-tree impl can take advantage of the fact that |
If you don't want to make the changes to Ideally we would make the Let me know which option you prefer. |
I'm happy to do the broader |
Alright, so we have three different bitset types--- rust/compiler/rustc_index/src/bit_set.rs Lines 213 to 225 in b5fe3bc
We want to change these to make both sides of the operation generic, just like (for example) Finally, you should expose the operations as inherent methods on each of the bitset types, just like the current code does. Once all that is done, it should be easy to add generic versions of Let me know if any of that is unclear, or if you have a better approach. And if you want to just do the |
I'm trying to understand the reason for having separate a |
That's correct. |
Still need to add comments and tests, but @ecstatic-morse can you let me know if this general design looks right to you? In short:
|
This comment has been minimized.
This comment has been minimized.
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.
Thanks @willcrichton!
I left a few notes. There's an issue I didn't foresee with the SparseBitSet
impls, which is going to cause problems, but for the most part this looks good.
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.
Almost there. All of my old review comments have been resolved satisfactorily. There's a bug and an unnecessary dense BitSet
allocation in the new code, however.
Can I ask for some unit tests for the new impls? I'm worried that I might have missed something just from staring at it.
This comment has been minimized.
This comment has been minimized.
@willcrichton, does running |
This comment has been minimized.
This comment has been minimized.
:O I didn't know that! Works like a charm, thanks. |
I usually run |
@ecstatic-morse I think this is about good. One last implementation issue. In the case of |
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.
Alright! This is basically there. I left one nit and one question. Thanks for sticking with it @willcrichton. Really we should be using proptest
or quickcheck
for better test coverage, but I don't think we can do that in-tree. We have smoke tests at least, and I've looked things over as carefully as I can. Next time we'll just make the private method public 😄.
Regarding the dense -> sparse transformation, I don't think we should try hard to make it happen. It's not always more efficient, since it can lead to thrashing when we're adding/subtracting elements while close to the threshold. I think the dense/sparse intersect case is worth it, since the result is guaranteed to be below the sparse threshold and it saves us from traversing the dense bitset to clear it, but that's pretty much the only case.
@bors try Just in case we've eliminated an optimized code path or messed with inlining thresholds. |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 86bd551 with merge 988d819e13d73f484d8370357ba9d1f8696de90f... |
☀️ Try build successful - checks-actions |
Queued 988d819e13d73f484d8370357ba9d1f8696de90f with parent 4a6547c, future comparison URL. |
Finished benchmarking try commit (988d819e13d73f484d8370357ba9d1f8696de90f): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. @bors rollup=never |
I gave this one last look today. Given the number of bugs found during the review process, it seemed wise. Everything (still) looks correct. For posterity, in addition to the @bors r+ |
📌 Commit e340a0e has been approved by |
☀️ Test successful - checks-actions |
I need the ability to clear the bits out of a row from
SparseBitMatrix
. Currently, all the mutating methods only allow insertion of bits, and there is no way to get access to the underlying data.One approach is simply to make
ensure_row
public, since it grants&mut
access to the underlyingHybridBitSet
. This PR adds thepub
modifier. However, presumably this method was private for a reason, so I'm open to other designs. I would prefer general mutable access to the rows, because that way I can add many mutating operations (clear
,intersect
, etc.) without filing a PR each time :-)r? @ecstatic-morse