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

Further sequester Group/Tag code #568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

clarfonthey
Copy link
Contributor

Was originally going to make this part of a larger change, but decided this bit is enough for its own PR.

Essentially, this completely moves the Group and Tag code outside of the raw module into a separate control module. This module will also eventually be the future home for stuff like RawIterHash and ProbeSeq, but I decided that that would be better as a separate PR, since moving and modifying the files makes it harder to review.

@@ -0,0 +1,35 @@
cfg_if! {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just copied directly from the raw module, without any additional changes.

Comment on lines +66 to +81
/// Extension trait for slices of tags.
pub(crate) trait TagSliceExt {
/// Fills the control with the given tag.
fn fill_tag(&mut self, tag: Tag);

/// Clears out the control.
fn fill_empty(&mut self) {
self.fill_tag(Tag::EMPTY)
}
}
impl TagSliceExt for [Tag] {
fn fill_tag(&mut self, tag: Tag) {
// SAFETY: We have access to the entire slice, so, we can write to the entire slice.
unsafe { self.as_mut_ptr().write_bytes(tag.0, self.len()) }
}
}
Copy link
Contributor Author

@clarfonthey clarfonthey Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new code.

The TagSliceExt was a mostly impulse decision to be able to do slice.fill_empty() instead of Tag::EMPTY.fill(slice), and since it's solely an internal API anyway it isn't a big deal. The most import part is that this lets us make the inside of a tag private relative to the raw module.

We're not able to just do slice.fill(Tag::EMPTY) and have it optimise into memset by itself, which is why this exists.

Comment on lines +52 to +64
impl fmt::Debug for Tag {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_special() {
if self.special_is_empty() {
f.pad("EMPTY")
} else {
f.pad("DELETED")
}
} else {
f.debug_tuple("full").field(&(self.0 & 0x7F)).finish()
}
}
}
Copy link
Contributor Author

@clarfonthey clarfonthey Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to replace the derived debug to help me debug the code I'm going to add in a future PR, so it's a bit easier to read. I figure that if we care about the additional compile time added by this one debug impl so much we can cfg(debug_assertions) gate it later.

@@ -0,0 +1,14 @@
// FIXME: Branch prediction hint. This is currently only available on nightly
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't feeling particularly creative and will need this in the control module too in the future, so, I decided to separate them into their own module.

Maybe nightly would be a better name, but I don't think it matters that much.

@bors
Copy link
Contributor

bors commented Oct 14, 2024

☔ The latest upstream changes (presumably #572) made this pull request unmergeable. Please resolve the merge conflicts.

@clarfonthey clarfonthey force-pushed the control-module-p1 branch 3 times, most recently from 3df96dd to 11f2cf9 Compare October 15, 2024 00:29
@@ -102,7 +102,7 @@ impl IntoIterator for BitMask {

/// Iterator over the contents of a `BitMask`, returning the indices of set
/// bits.
#[derive(Copy, Clone)]
#[derive(Clone)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterators in general shouldn't implement Copy, for better or worse.

@clarfonthey
Copy link
Contributor Author

So, I figured out why my probing logic wasn't working: it wasn't because it wasn't working, but because my debug-assert checking that it was working wasn't working, and giving me false positives. So, #578 exists to demonstrate the fuller version of the control module so you can get an idea where I'm coming from with this change, even though this should be merged first.

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.

2 participants