Spread native volume cache keys

- Mix chunk keys so origin and query caches stop treeifying buckets
This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-28 11:36:50 -04:00
1 parent 2f8d3b1d1a
commit 8878e9aa5f
2 files changed
+32

No files matched your search

@@ -0,0 +1,23 @@
package art.arcane.iris.structure.nativegen;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class NativeStructureVolumeIndexKeyTest {
@Test
public void neighbouringChunkKeysSpreadAcrossHashBuckets() {
IntOpenHashSet buckets = new IntOpenHashSet();
int keys = 0;
for (int chunkX = -64; chunkX < 64; chunkX++) {
for (int chunkZ = -64; chunkZ < 64; chunkZ++) {
long chunkKey = ((long) chunkX << 32) ^ (chunkZ & 0xffffffffL);
int hash = NativeStructureVolumeIndex.runtimeChunkHash(7, chunkKey);
buckets.add((hash ^ (hash >>> 16)) & ((1 << 15) - 1));
keys++;
}
}
assertTrue("buckets=" + buckets.size(), buckets.size() > keys / 2);
}
}