Performance improvements + Fix packet sending

Async flush the changeset (sync flush for undo when needed)
- Not any faster, but edits will feel significantly faster
Fix incorrect bit mask for fixlighting packet sending
This commit is contained in:
Jesse Boyd 2016-09-26 01:53:13 +10:00
parent 7c96547c68
commit 3306bd2cdc
6 changed files with 32 additions and 11 deletions

View File

@ -431,7 +431,7 @@ public class FaweAPI {
NMSRelighter relighter = new NMSRelighter(nmsQueue);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z ++) {
relighter.addChunk(x, z, null, 65536);
relighter.addChunk(x, z, null, 65535);
count++;
}
}

View File

@ -106,7 +106,7 @@ public class Settings extends Config {
public static boolean COMBINE_STAGES = true;
@Comment({
"Higher compression reduces the size of history at the expense of CPU",
"0 = Uncompressed byte array",
"0 = Uncompressed byte array (fastest)",
"1 = 1 pass fast compressor (default)",
"2 = 2 x fast",
"3 = 3 x fast",
@ -115,8 +115,8 @@ public class Settings extends Config {
"6 = 1 x medium, 3 x fast",
"7 = 1 x high, 1 x medium, 1 x fast",
"8 = 1 x high, 1 x medium, 2 x fast",
"9 = 1 x high, 1 x medium, 3 x fast",
"NOTE: If using disk, do some compression as smaller files save faster"
"9 = 1 x high, 1 x medium, 3 x fast (best compression)",
"NOTE: If using disk, do some compression (3+) as smaller files save faster"
})
public static int COMPRESSION_LEVEL = 1;
@Comment({

View File

@ -52,6 +52,18 @@ public abstract class FaweChangeSet implements ChangeSet {
return world;
}
public boolean flushAsync() {
waiting.incrementAndGet();
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
waiting.decrementAndGet();
flush();
}
});
return true;
}
public boolean flush() {
try {
while (waiting.get() > 0) {

View File

@ -1182,8 +1182,13 @@ public class EditSession extends AbstractWorld implements HasFaweQueue {
queue.flush();
}
if (getChangeSet() != null) {
if (Settings.HISTORY.COMBINE_STAGES) {
((FaweChangeSet) getChangeSet()).flushAsync();
} else {
((FaweChangeSet) getChangeSet()).flush();
}
}
}
@Override

View File

@ -423,7 +423,10 @@ public class LocalSession {
private FaweChangeSet getChangeSet(Object o) {
if (o instanceof FaweChangeSet) {
return (FaweChangeSet) o;
FaweChangeSet cs = (FaweChangeSet) o;
MainUtil.stacktrace();
cs.flush();
return cs;
}
if (o instanceof Integer) {
return new DiskStorageHistory(currentWorld, this.uuid, (Integer) o);
@ -466,8 +469,6 @@ public class LocalSession {
}
}
FaweChangeSet changeSet = (FaweChangeSet) editSession.getChangeSet();
// Just in case
changeSet.flush();
historySize += MainUtil.getSize(changeSet);
if (append) {
history.add(changeSet);

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.extension.platform;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.command.AnvilCommands;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
import com.boydti.fawe.object.exception.FaweException;
@ -334,6 +335,7 @@ public final class CommandManager {
final long time = System.currentTimeMillis() - start;
if (time > 5 && hasSession) {
BBC.ACTION_COMPLETE.send(finalActor, (time / 1000d));
if (!Settings.HISTORY.COMBINE_STAGES) { // If stages are combined, we don't know the size yet (async flush)
ChangeSet fcs = editSession.getChangeSet();
if (fcs != null && fcs instanceof FaweStreamChangeSet) {
MainUtil.sendCompressedMessage((FaweStreamChangeSet) fcs, fp);
@ -342,6 +344,7 @@ public final class CommandManager {
}
}
}
}
}, checkLimit, false)) {
BBC.WORLDEDIT_COMMAND_LIMIT.send(fp);
}