mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Clipped pregen prefetch
- Limited chunk prefetch rings to the windows a bounded pregeneration still needs - Forwarded pregeneration region bounds from the async, medieval and modded methods - Restored unclipped prefetch when the pregeneration closes - Added a runtime test for clipped and restored prefetch
This commit is contained in:
1 parent
ca33273d17
commit
def73cff96
7 files changed
+116
-1
No files matched your search
+30
@@ -67,6 +67,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -414,6 +415,35 @@ public class HydrologyRuntimeTest {
|
||||
assertEquals(3, prefetches.get());
|
||||
}
|
||||
|
||||
@Test(timeout = 180_000L)
|
||||
public void boundedPregenerationPrefetchesOnlyWindowsItsChunksNeed() {
|
||||
FakePlanners planners = new FakePlanners(settings());
|
||||
HydrologyPlanCache cache = spy(new HydrologyPlanCache(planners.settings, planners::region, planners::window,
|
||||
pool(planners, 2), () -> false));
|
||||
List<int[]> prepared = Collections.synchronizedList(new ArrayList<>());
|
||||
doAnswer(invocation -> {
|
||||
prepared.add(new int[]{invocation.getArgument(0), invocation.getArgument(1), invocation.getArgument(2), invocation.getArgument(3),
|
||||
invocation.getArgument(4)});
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}).when(cache).prepareWindowsAround(anyInt(), anyInt(), anyInt(), anyInt(), anyInt());
|
||||
HydrologyRuntime runtime = new HydrologyRuntime(planners.settings, cache, planners::natural, () -> false, planners.ticker::get);
|
||||
runtimes.add(runtime);
|
||||
int chunks = WindowKey.SIZE >> 4;
|
||||
HydrologyPregeneration pregeneration = runtime.openPregeneration();
|
||||
pregeneration.bound(0, 0, 1, 1);
|
||||
|
||||
runtime.raster(0, 0);
|
||||
assertArrayEquals(new int[]{-chunks, -chunks, 3 * chunks - 1, 3 * chunks - 1, 0}, prepared.getLast());
|
||||
runtime.raster(chunks + 5, chunks + 5);
|
||||
assertArrayEquals(new int[]{-chunks, -chunks, 3 * chunks - 1, 3 * chunks - 1, 0}, prepared.getLast());
|
||||
runtime.raster(-3 * chunks, 0);
|
||||
assertArrayEquals(new int[]{-3 * chunks, 0, -3 * chunks, 0, 2}, prepared.getLast());
|
||||
|
||||
pregeneration.close();
|
||||
runtime.raster(1, 1);
|
||||
assertArrayEquals(new int[]{1, 1, 1, 1, 2}, prepared.getLast());
|
||||
}
|
||||
|
||||
@Test(timeout = 180_000L)
|
||||
public void preparePregenerationPlansRegionsInOrder() throws Exception {
|
||||
FakePlanners planners = new FakePlanners(settings());
|
||||
|
||||
Reference in new issue
Block a user