mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-30 20:39:21 +00:00
switch to burst
This commit is contained in:
@@ -100,7 +100,7 @@ public class IrisEngineSVC implements IrisService {
|
||||
Engine engine = supplier.get();
|
||||
if (engine != null) {
|
||||
long unloadStart = System.currentTimeMillis();
|
||||
int count = engine.getMantle().unloadTectonicPlate();
|
||||
int count = engine.getMantle().unloadTectonicPlate(tectonicLimit.get() / lastUse.size());
|
||||
if (count > 0) {
|
||||
Iris.debug(C.GOLD + "Unloaded " + C.YELLOW + count + " TectonicPlates in " + C.RED + Form.duration(System.currentTimeMillis() - unloadStart, 2));
|
||||
}
|
||||
|
||||
@@ -178,8 +178,8 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
default void trim(int limit) {
|
||||
getMantle().trim(TimeUnit.SECONDS.toMillis(IrisSettings.get().getPerformance().getMantleKeepAlive()), limit);
|
||||
}
|
||||
default int unloadTectonicPlate(){
|
||||
return getMantle().unloadTectonicPlate();
|
||||
default int unloadTectonicPlate(int tectonicLimit){
|
||||
return getMantle().unloadTectonicPlate(tectonicLimit);
|
||||
}
|
||||
|
||||
default MultiBurst burst() {
|
||||
|
||||
@@ -444,15 +444,15 @@ public class Mantle {
|
||||
}
|
||||
}
|
||||
|
||||
public int unloadTectonicPlate() {
|
||||
public int unloadTectonicPlate(int tectonicLimit) {
|
||||
// todo: Make it advanced with bursts etc
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
unloadLock.lock();
|
||||
try {
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
ExecutorService service = Executors.newFixedThreadPool(dynamicThreads.get());
|
||||
BurstExecutor burst = MultiBurst.burst.burst(toUnload.size());
|
||||
burst.setMulticore(toUnload.size() > tectonicLimit);
|
||||
for (long id : new ArrayList<>(toUnload)) {
|
||||
futures.add(service.submit(() ->
|
||||
burst.queue(() ->
|
||||
hyperLock.withLong(id, () -> {
|
||||
TectonicPlate m = loadedRegions.get(id);
|
||||
if (m != null) {
|
||||
@@ -467,16 +467,10 @@ public class Mantle {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
})));
|
||||
}));
|
||||
}
|
||||
|
||||
try {
|
||||
while (!futures.isEmpty()) {
|
||||
futures.remove(0).get();
|
||||
futures.removeIf(Future::isDone);
|
||||
}
|
||||
service.shutdown();
|
||||
} catch (InterruptedException ignored) {}
|
||||
burst.complete();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user