3
0

Some portion of optimizations:

* Clear outgoing packet queue after player disconnect
* Disable sleep between chunk saving
* Put 2x4096 bytes instead 2048x4 bytes for region file aligment
* Using map to search player by name instead iterating over all players
* Some tweaks for decorations (item frames, maps)
This commit is contained in:
Prototik
2015-10-18 23:58:28 +07:00
parent 299cf0ed96
commit 7defe0bb29
17 changed files with 225 additions and 41 deletions

View File

@ -0,0 +1,33 @@
--- ../src-base/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
+++ ../src-work/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
@@ -43,7 +43,8 @@
if (this.dataFile.length() < 4096L)
{
- for (i = 0; i < 1024; ++i)
+ // KCauldron start
+ /*for (i = 0; i < 1024; ++i)
{
this.dataFile.writeInt(0);
}
@@ -51,7 +52,10 @@
for (i = 0; i < 1024; ++i)
{
this.dataFile.writeInt(0);
- }
+ }*/
+ dataFile.write(emptySector);
+ dataFile.write(emptySector);
+ // KCauldron end
this.sizeDelta += 8192;
}
@@ -209,7 +213,7 @@
public DataOutputStream getChunkDataOutputStream(int p_76710_1_, int p_76710_2_)
{
- return this.outOfBounds(p_76710_1_, p_76710_2_) ? null : new DataOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(p_76710_1_, p_76710_2_)));
+ return this.outOfBounds(p_76710_1_, p_76710_2_) ? null : new DataOutputStream(new java.io.BufferedOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(p_76710_1_, p_76710_2_)))); // KCauldron
}
protected synchronized void write(int p_76706_1_, int p_76706_2_, byte[] p_76706_3_, int p_76706_4_)

View File

@ -15,10 +15,12 @@
public class MapData extends WorldSavedData
{
public int xCenter;
@@ -24,11 +32,21 @@
@@ -23,12 +31,22 @@
public byte[] colors = new byte[16384];
public List playersArrayList = new ArrayList();
private Map playersHashMap = new HashMap();
public Map playersVisibleOnMap = new LinkedHashMap();
- public Map playersVisibleOnMap = new LinkedHashMap();
+ public Map<UUID, MapData.MapCoord> playersVisibleOnMap = new LinkedHashMap();
+
+ // CraftBukkit start
+ public final CraftMapView mapView;
@ -37,7 +39,7 @@
}
public void readFromNBT(NBTTagCompound p_76184_1_)
@@ -107,7 +125,7 @@
@@ -107,14 +125,14 @@
{
if (!this.playersHashMap.containsKey(p_76191_1_))
{
@ -46,6 +48,41 @@
this.playersHashMap.put(p_76191_1_, mapinfo);
this.playersArrayList.add(mapinfo);
}
if (!p_76191_1_.inventory.hasItemStack(p_76191_2_))
{
- this.playersVisibleOnMap.remove(p_76191_1_.getCommandSenderName());
+ this.playersVisibleOnMap.remove(p_76191_1_.getUniqueID());
}
for (int i = 0; i < this.playersArrayList.size(); ++i)
@@ -166,7 +184,7 @@
{
if (Math.abs(f) >= 320.0F || Math.abs(f1) >= 320.0F)
{
- this.playersVisibleOnMap.remove(p_82567_3_);
+ this.playersVisibleOnMap.remove(java.util.UUID.nameUUIDFromBytes(p_82567_3_.getBytes(org.apache.commons.codec.Charsets.US_ASCII)));
return;
}
@@ -194,7 +212,7 @@
}
}
- this.playersVisibleOnMap.put(p_82567_3_, new MapData.MapCoord((byte)p_82567_1_, b0, b1, b2));
+ this.playersVisibleOnMap.put(java.util.UUID.nameUUIDFromBytes(p_82567_3_.getBytes(org.apache.commons.codec.Charsets.US_ASCII)), new MapData.MapCoord((byte)p_82567_1_, b0, b1, b2));
}
public byte[] getUpdatePacketData(ItemStack p_76193_1_, World p_76193_2_, EntityPlayer p_76193_3_)
@@ -250,7 +268,7 @@
byte b3 = p_76192_1_[i * 3 + 2];
byte b0 = p_76192_1_[i * 3 + 3];
byte b1 = (byte)(p_76192_1_[i * 3 + 1] & 15);
- this.playersVisibleOnMap.put("icon-" + i, new MapData.MapCoord(b2, b3, b0, b1));
+ this.playersVisibleOnMap.put(java.util.UUID.nameUUIDFromBytes(("icon-" + i).getBytes(org.apache.commons.codec.Charsets.US_ASCII)), new MapData.MapCoord(b2, b3, b0, b1));
}
}
else if (p_76192_1_[0] == 2)
@@ -265,7 +283,7 @@
if (mapinfo == null)

View File

@ -0,0 +1,19 @@
--- ../src-base/minecraft/net/minecraft/world/storage/ThreadedFileIOBase.java
+++ ../src-work/minecraft/net/minecraft/world/storage/ThreadedFileIOBase.java
@@ -39,14 +39,14 @@
++this.savedIOCounter;
}
- try
+ /*try // KCauldron start
{
Thread.sleep(this.isThreadWaiting ? 0L : 10L);
}
catch (InterruptedException interruptedexception1)
{
interruptedexception1.printStackTrace();
- }
+ }*/ // KCauldron end
}
if (this.threadedIOQueue.isEmpty())