mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 22:10:18 +00:00
Merged threads and hydrology
- Bounded hydrology halo, performance-core pools
This commit is contained in:
commit
f283d482a4
6 files changed
+47
-8
No files matched your search
@@ -26,7 +26,7 @@ public class MultiBurst extends MultiBurstSupport {
|
|||||||
private final AtomicInteger parallelismBaseline = new AtomicInteger();
|
private final AtomicInteger parallelismBaseline = new AtomicInteger();
|
||||||
|
|
||||||
public MultiBurst() {
|
public MultiBurst() {
|
||||||
this("Iris");
|
this("Iris", Thread.MIN_PRIORITY, MultiBurstSupport::performanceProcessors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiBurst(String name) {
|
public MultiBurst(String name) {
|
||||||
@@ -140,8 +140,15 @@ public class MultiBurst extends MultiBurstSupport {
|
|||||||
|
|
||||||
static final class HydrologyBurst extends MultiBurst {
|
static final class HydrologyBurst extends MultiBurst {
|
||||||
HydrologyBurst() {
|
HydrologyBurst() {
|
||||||
super("Iris Hydrology", () -> Math.max(2,
|
super("Iris Hydrology", HydrologyBurst::plannerParallelism);
|
||||||
IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())));
|
}
|
||||||
|
|
||||||
|
static int plannerParallelism() {
|
||||||
|
return plannerParallelism(MultiBurstSupport.performanceProcessors());
|
||||||
|
}
|
||||||
|
|
||||||
|
static int plannerParallelism(int performanceProcessors) {
|
||||||
|
return Math.max(4, performanceProcessors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public final class HydrologyTileCache implements AutoCloseable {
|
|||||||
private static final byte AROUND_EMPTY = 1;
|
private static final byte AROUND_EMPTY = 1;
|
||||||
private static final byte AROUND_PUBLISHED = 2;
|
private static final byte AROUND_PUBLISHED = 2;
|
||||||
private static final int MAXIMUM_PREGENERATION_TILES = 4096;
|
private static final int MAXIMUM_PREGENERATION_TILES = 4096;
|
||||||
private static final int PREGENERATION_HALO_BLOCKS = 512;
|
private static final int PREGENERATION_HALO_BLOCKS = 256;
|
||||||
private static final HydrologyColumnSample[] NO_COLUMNS = new HydrologyColumnSample[CHUNK_COLUMN_COUNT];
|
private static final HydrologyColumnSample[] NO_COLUMNS = new HydrologyColumnSample[CHUNK_COLUMN_COUNT];
|
||||||
private static final Cache<SharedTileKey, HydrologyTile> SHARED_TILES = Caffeine.newBuilder()
|
private static final Cache<SharedTileKey, HydrologyTile> SHARED_TILES = Caffeine.newBuilder()
|
||||||
.maximumWeight(HydrologyCacheBudget.sharedStudioBytes())
|
.maximumWeight(HydrologyCacheBudget.sharedStudioBytes())
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import art.arcane.iris.generation.runtime.Engine;
|
|||||||
import art.arcane.iris.platform.generation.PlatformChunkGenerator;
|
import art.arcane.iris.platform.generation.PlatformChunkGenerator;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.generation.concurrent.MultiBurst;
|
import art.arcane.iris.generation.concurrent.MultiBurst;
|
||||||
|
import art.arcane.volmlib.util.parallel.MultiBurstSupport;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@@ -45,7 +46,7 @@ public final class PregenPerformanceProfile {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MultiBurst.burst.raiseParallelism(pregenBurstParallelism(Runtime.getRuntime().availableProcessors()))) {
|
if (MultiBurst.burst.raiseParallelism(pregenBurstParallelism(MultiBurstSupport.performanceProcessors()))) {
|
||||||
PARALLELISM_HOLDERS.incrementAndGet();
|
PARALLELISM_HOLDERS.incrementAndGet();
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -88,8 +89,8 @@ public final class PregenPerformanceProfile {
|
|||||||
apply(generator == null ? null : generator.getEngine());
|
apply(generator == null ? null : generator.getEngine());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pregenBurstParallelism(int availableProcessors) {
|
static int pregenBurstParallelism(int performanceProcessors) {
|
||||||
return Math.max(4, availableProcessors * 2);
|
return Math.max(4, performanceProcessors * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void prepareNoiseCacheInPlace(Engine engine) {
|
private static void prepareNoiseCacheInPlace(Engine engine) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.concurrent.ForkJoinTask;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.Assert.assertNotSame;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -60,6 +61,13 @@ public class HydrologyBurstTest {
|
|||||||
assertTrue(pool.isTerminated());
|
assertTrue(pool.isTerminated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void plannerPoolFollowsThePerformanceCores() {
|
||||||
|
assertEquals(12, MultiBurst.HydrologyBurst.plannerParallelism(12));
|
||||||
|
assertEquals(4, MultiBurst.HydrologyBurst.plannerParallelism(1));
|
||||||
|
assertEquals(32, MultiBurst.HydrologyBurst.plannerParallelism(32));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void closedHydrologyWorkersTerminateAndReopenCreatesANewPool() throws Exception {
|
public void closedHydrologyWorkersTerminateAndReopenCreatesANewPool() throws Exception {
|
||||||
IrisSettings previousSettings = IrisSettings.settings;
|
IrisSettings previousSettings = IrisSettings.settings;
|
||||||
|
|||||||
@@ -696,6 +696,29 @@ public class HydrologyTileCacheTest {
|
|||||||
cache.close();
|
cache.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void pregenSpeculationStaysWithinTheGenerationReachOfTheArea() {
|
||||||
|
HydrologyPlanner planner = mock(HydrologyPlanner.class);
|
||||||
|
HydrologyTile tile = mock(HydrologyTile.class);
|
||||||
|
HydrologyPlannerSettings settings = stalePrefetchSettings();
|
||||||
|
when(planner.settings()).thenReturn(settings);
|
||||||
|
ArrayList<HydrologyTileKey> planned = new ArrayList<>();
|
||||||
|
doAnswer(invocation -> {
|
||||||
|
planned.add(invocation.getArgument(0));
|
||||||
|
return tile;
|
||||||
|
}).when(planner).plan(any(HydrologyTileKey.class));
|
||||||
|
HydrologyTileCache cache = new HydrologyTileCache(planner, 128, Runnable::run);
|
||||||
|
try (HydrologyTileCache.PregenerationScope ignored = cache.preparePregeneration(
|
||||||
|
new HydrologyTileCache.PregenerationArea(1024, 1024, 736, 736, 1311, 1311))) {
|
||||||
|
assertEquals(prefetchRectangle(0, 1, 0, 1), new HashSet<>(planned));
|
||||||
|
cache.prepareChunkColumns(800, 800);
|
||||||
|
cache.prepareChunkColumns(1300, 1300);
|
||||||
|
assertEquals(prefetchRectangle(0, 1, 0, 1), new HashSet<>(planned));
|
||||||
|
assertEquals(4, planned.size());
|
||||||
|
}
|
||||||
|
cache.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pregenScopesRestoreStudioPrefetchAndIgnoreSupersededClose() {
|
public void pregenScopesRestoreStudioPrefetchAndIgnoreSupersededClose() {
|
||||||
HydrologyPlanner planner = mock(HydrologyPlanner.class);
|
HydrologyPlanner planner = mock(HydrologyPlanner.class);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class PregenPerformanceProfileTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pregenerationWantsTwoBurstWorkersPerCore() {
|
public void pregenerationWantsTwoBurstWorkersPerPerformanceCore() {
|
||||||
assertEquals(32, PregenPerformanceProfile.pregenBurstParallelism(16));
|
assertEquals(32, PregenPerformanceProfile.pregenBurstParallelism(16));
|
||||||
assertEquals(4, PregenPerformanceProfile.pregenBurstParallelism(1));
|
assertEquals(4, PregenPerformanceProfile.pregenBurstParallelism(1));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user