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