- const BUCKET_START_POS: [u16; 33] = [
- 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3072, 4096, 6144, 8192, 10240, 12288,
- 13312, 14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383, 16384,
- ];
+ // By default u16s may not be cache-aligned, but we'd rather not have to read a third cache
+ // line just to access it
+ #[repr(align(128))]
+ struct BucketStartPos([u16; 33]);
+ impl BucketStartPos {
+ const fn new() -> Self {
+ Self([
+ 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3072, 4096, 6144, 8192, 10240, 12288,
+ 13312, 14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383, 16384,
+ ])
+ }
+ }
+ impl core::ops::Index<usize> for BucketStartPos {
+ type Output = u16;
+ #[inline(always)]
+ fn index(&self, index: usize) -> &u16 { &self.0[index] }
+ }
+ const BUCKET_START_POS: BucketStartPos = BucketStartPos::new();