From 71422d5452d44c7bea9afd13097e283b4a0733b0 Mon Sep 17 00:00:00 2001 From: ltdk Date: Sat, 7 Dec 2024 18:21:21 -0500 Subject: [PATCH] Double the width of static allocations for empty tables --- src/control/group/generic.rs | 9 ++++++--- src/control/group/neon.rs | 9 ++++++--- src/control/group/sse2.rs | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/control/group/generic.rs b/src/control/group/generic.rs index 223070997..c22098687 100644 --- a/src/control/group/generic.rs +++ b/src/control/group/generic.rs @@ -50,20 +50,23 @@ impl Group { /// Number of bytes in the group. pub(crate) const WIDTH: usize = mem::size_of::(); + /// Double the group width; size of [`Group::static_empty`]. + pub(crate) const DOUBLE_WIDTH: usize = Group::WIDTH * 2; + /// Returns a full group of empty tags, suitable for use as the initial /// value for an empty hash table. /// /// This is guaranteed to be aligned to the group size. #[inline] - pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] { + pub(crate) const fn static_empty() -> &'static [Tag; Group::DOUBLE_WIDTH] { #[repr(C)] struct AlignedTags { _align: [Group; 0], - tags: [Tag; Group::WIDTH], + tags: [Tag; Group::DOUBLE_WIDTH], } const ALIGNED_TAGS: AlignedTags = AlignedTags { _align: [], - tags: [Tag::EMPTY; Group::WIDTH], + tags: [Tag::EMPTY; Group::DOUBLE_WIDTH], }; &ALIGNED_TAGS.tags } diff --git a/src/control/group/neon.rs b/src/control/group/neon.rs index 9374cb388..25d281444 100644 --- a/src/control/group/neon.rs +++ b/src/control/group/neon.rs @@ -21,20 +21,23 @@ impl Group { /// Number of bytes in the group. pub(crate) const WIDTH: usize = mem::size_of::(); + /// Double the group width; size of [`Group::static_empty`]. + pub(crate) const DOUBLE_WIDTH: usize = Group::WIDTH * 2; + /// Returns a full group of empty tags, suitable for use as the initial /// value for an empty hash table. /// /// This is guaranteed to be aligned to the group size. #[inline] - pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] { + pub(crate) const fn static_empty() -> &'static [Tag; Group::DOUBLE_WIDTH] { #[repr(C)] struct AlignedTags { _align: [Group; 0], - tags: [Tag; Group::WIDTH], + tags: [Tag; Group::DOUBLE_WIDTH], } const ALIGNED_TAGS: AlignedTags = AlignedTags { _align: [], - tags: [Tag::EMPTY; Group::WIDTH], + tags: [Tag::EMPTY; Group::DOUBLE_WIDTH], }; &ALIGNED_TAGS.tags } diff --git a/src/control/group/sse2.rs b/src/control/group/sse2.rs index 0d4b10822..72e1d5b44 100644 --- a/src/control/group/sse2.rs +++ b/src/control/group/sse2.rs @@ -26,21 +26,24 @@ impl Group { /// Number of bytes in the group. pub(crate) const WIDTH: usize = mem::size_of::(); + /// Double the group width; size of [`Group::static_empty`]. + pub(crate) const DOUBLE_WIDTH: usize = Group::WIDTH * 2; + /// Returns a full group of empty tags, suitable for use as the initial /// value for an empty hash table. /// /// This is guaranteed to be aligned to the group size. #[inline] #[allow(clippy::items_after_statements)] - pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] { + pub(crate) const fn static_empty() -> &'static [Tag; Group::DOUBLE_WIDTH] { #[repr(C)] struct AlignedTags { _align: [Group; 0], - tags: [Tag; Group::WIDTH], + tags: [Tag; Group::DOUBLE_WIDTH], } const ALIGNED_TAGS: AlignedTags = AlignedTags { _align: [], - tags: [Tag::EMPTY; Group::WIDTH], + tags: [Tag::EMPTY; Group::DOUBLE_WIDTH], }; &ALIGNED_TAGS.tags }