Various minor

fix undo null sections
fix cancel for certain parallel jobs
optimize schem paste
This commit is contained in:
Jesse Boyd
2019-11-17 22:47:56 +00:00
parent 0394f3516b
commit 0087a0d6ab
11 changed files with 49 additions and 36 deletions

View File

@ -28,10 +28,8 @@ public abstract class CharBlocks implements IBlocks {
throw new IllegalStateException("Array cannot be null (update): " + blocks.getClass());
}
}
synchronized (this) {
if (blocks.blocks[layer] != null) {
blocks.sections[layer] = FULL;
}
if (blocks.blocks[layer] != null) {
blocks.sections[layer] = FULL;
}
return arr;
}
@ -52,11 +50,7 @@ public abstract class CharBlocks implements IBlocks {
boolean result = true;
for (int i = 0; i < 16; i++) {
if (sections[i] == EMPTY && blocks[i] != null) {
synchronized (this) {
if (sections[i] == EMPTY && blocks[i] != null) {
blocks[i] = null;
}
}
blocks[i] = null;
} else {
result = false;
}

View File

@ -21,11 +21,9 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
@Override
public boolean trim(boolean aggressive) {
synchronized (this) {
for (int i = 0; i < 16; i++) {
sections[i] = EMPTY;
blocks[i] = null;
}
for (int i = 0; i < 16; i++) {
sections[i] = EMPTY;
blocks[i] = null;
}
return true;
}

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.beta.implementation.queue;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IQueueWrapper;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.Filter;
@ -10,6 +11,7 @@ import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
import com.boydti.fawe.object.extent.NullExtent;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent;
@ -56,6 +58,15 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
return (IQueueExtent) super.getExtent();
}
@Override
public boolean cancel() {
if (super.cancel()) {
processor.setProcessor(new NullExtent(this, FaweCache.MANUAL));
return true;
}
return false;
}
private IQueueExtent getNewQueue() {
return wrapQueue(handler.getQueue(this.world, this.processor));
}

View File

@ -81,6 +81,10 @@ public abstract class QueueHandler implements Trimable, Runnable {
}
}
public boolean isUnderutilized() {
return blockingExecutor.getActiveCount() < blockingExecutor.getMaximumPoolSize();
}
private long getAllocate() {
long now = System.currentTimeMillis();
targetTPS = 18 - Math.max(Settings.IMP.QUEUE.EXTRA_TIME_MS * 0.05, 0);

View File

@ -221,17 +221,20 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
}
final int size = chunks.size();
final boolean lowMem = MemUtil.isMemoryLimited();
if (enabledQueue && (lowMem || size > Settings.IMP.QUEUE.TARGET_SIZE)) {
// If queueing is enabled AND either of the following
// - memory is low & queue size > num threads + 8
// - queue size > target size and primary queue has less than num threads submissions
if (enabledQueue && ((lowMem && size > Settings.IMP.QUEUE.PARALLEL_THREADS + 8) || (size > Settings.IMP.QUEUE.TARGET_SIZE && Fawe.get().getQueueHandler().isUnderutilized()))) {
chunk = chunks.removeFirst();
final Future future = submitUnchecked(chunk);
if (future != null && !future.isDone()) {
final int targetSize;
if (lowMem) {
targetSize = Settings.IMP.QUEUE.PARALLEL_THREADS;
targetSize = Settings.IMP.QUEUE.PARALLEL_THREADS + 8;
} else {
targetSize = Settings.IMP.QUEUE.TARGET_SIZE;
}
pollSubmissions(targetSize, true);
pollSubmissions(targetSize, lowMem);
submissions.add(future);
}
}