mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 22:10:18 +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
@@ -8,6 +8,7 @@ import art.arcane.volmlib.nativelib.terrain.structure.NativeStructureVolume;
|
|||||||
import art.arcane.iris.generation.runtime.IrisEngine;
|
import art.arcane.iris.generation.runtime.IrisEngine;
|
||||||
import art.arcane.iris.generation.runtime.Engine;
|
import art.arcane.iris.generation.runtime.Engine;
|
||||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||||
|
import art.arcane.volmlib.util.cache.CacheKey;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -313,7 +314,15 @@ public final class NativeStructureVolumeIndex {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int runtimeChunkHash(int runtimeId, long chunkKey) {
|
||||||
|
return Long.hashCode(CacheKey.mix(chunkKey)) * 31 + runtimeId;
|
||||||
|
}
|
||||||
|
|
||||||
private record RuntimeChunkKey(int runtimeId, long chunkKey) {
|
private record RuntimeChunkKey(int runtimeId, long chunkKey) {
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return runtimeChunkHash(runtimeId, chunkKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+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