mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
Spread native volume cache keys
- Mix chunk keys so origin and query caches stop treeifying buckets
This commit is contained in:
1 parent
2f8d3b1d1a
commit
8878e9aa5f
2 files changed
+32
No files matched your search
+23
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user