Port Stop-copy-on-write-operations-for-updating-light-dat

This commit is contained in:
KennyTV 2021-06-15 17:43:00 +02:00
parent eab6d9f533
commit 7480cf008a
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
234 changed files with 122 additions and 147 deletions

View File

@ -5,25 +5,23 @@ Subject: [PATCH] Stop copy-on-write operations for updating light data
Causes huge memory allocations + gc issues Causes huge memory allocations + gc issues
1.17 update note: Needs updating, temp skipped
diff --git a/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java diff --git a/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java
index 9f33fa8f84d10f8f4089030074ad6c0d81269ce8..a1ad4d73ddaf6afe97a1f1ff7e0622b52fac8761 100644 index 573cdb0897978eef8f5fc906ed4928293f4b2ab9..314b46f0becd088d26956b45981217b128d539cb 100644
--- a/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java --- a/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java
+++ b/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java +++ b/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java
@@ -10,7 +10,7 @@ import net.minecraft.world.level.chunk.LightChunkGetter; @@ -9,7 +9,7 @@ import net.minecraft.world.level.chunk.LightChunkGetter;
public class BlockLightSectionStorage extends LayerLightSectionStorage<BlockLightSectionStorage.BlockDataLayerStorageMap> {
public class BlockLightSectionStorage extends LayerLightSectionStorage<BlockLightSectionStorage.BlockDataLayerStorageMap> {
protected BlockLightSectionStorage(LightChunkGetter chunkProvider) { protected BlockLightSectionStorage(LightChunkGetter chunkProvider) {
- super(LightLayer.BLOCK, chunkProvider, new BlockLightSectionStorage.BlockDataLayerStorageMap(new Long2ObjectOpenHashMap())); - super(LightLayer.BLOCK, chunkProvider, new BlockLightSectionStorage.BlockDataLayerStorageMap(new Long2ObjectOpenHashMap<>()));
+ super(LightLayer.BLOCK, chunkProvider, new BlockLightSectionStorage.BlockDataLayerStorageMap(new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<>(), false)); // Paper - avoid copying light data + super(LightLayer.BLOCK, chunkProvider, new BlockLightSectionStorage.BlockDataLayerStorageMap(new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<>(), false)); // Paper - avoid copying light data
} }
@Override @Override
@@ -23,13 +23,13 @@ public class BlockLightSectionStorage extends LayerLightSectionStorage<BlockLigh @@ -20,13 +20,13 @@ public class BlockLightSectionStorage extends LayerLightSectionStorage<BlockLigh
}
public static final class BlockDataLayerStorageMap extends DataLayerStorageMap<BlockLightSectionStorage.BlockDataLayerStorageMap> {
protected static final class BlockDataLayerStorageMap extends DataLayerStorageMap<BlockLightSectionStorage.BlockDataLayerStorageMap> {
- public BlockDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays) { - public BlockDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays) {
- super(arrays); - super(arrays);
+ public BlockDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> long2objectopenhashmap, boolean isVisible) { // Paper - avoid copying light data + public BlockDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> long2objectopenhashmap, boolean isVisible) { // Paper - avoid copying light data
@ -38,7 +36,7 @@ index 9f33fa8f84d10f8f4089030074ad6c0d81269ce8..a1ad4d73ddaf6afe97a1f1ff7e0622b5
} }
} }
diff --git a/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java b/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java diff --git a/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java b/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java
index 01ae1c811862f56317a90e3811fe2ef4b593695f..4c9041f1c1cb4b3ec114fbd0c5d4db50a6f2526d 100644 index 67ff66e232592203cf8dad605ad01eabc4dded89..f357a3473682c2d37a20fb862522c67b9979402a 100644
--- a/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java --- a/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java
+++ b/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java +++ b/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java
@@ -9,10 +9,23 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> { @@ -9,10 +9,23 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
@ -46,13 +44,12 @@ index 01ae1c811862f56317a90e3811fe2ef4b593695f..4c9041f1c1cb4b3ec114fbd0c5d4db50
private final DataLayer[] lastSections = new DataLayer[2]; private final DataLayer[] lastSections = new DataLayer[2];
private boolean cacheEnabled; private boolean cacheEnabled;
- protected final Long2ObjectOpenHashMap<DataLayer> map; - protected final Long2ObjectOpenHashMap<DataLayer> map;
-
- protected DataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays) {
- this.map = arrays;
+ protected final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> data; // Paper - avoid copying light data + protected final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> data; // Paper - avoid copying light data
+ protected final boolean isVisible; // Paper - avoid copying light data + protected final boolean isVisible; // Paper - avoid copying light data
+ java.util.function.Function<Long, DataLayer> lookup; // Paper - faster branchless lookup + java.util.function.Function<Long, DataLayer> lookup; // Paper - faster branchless lookup
+
- protected DataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays) {
- this.map = arrays;
+ // Paper start - avoid copying light data + // Paper start - avoid copying light data
+ protected DataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> data, boolean isVisible) { + protected DataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> data, boolean isVisible) {
+ if (isVisible) { + if (isVisible) {
@ -73,7 +70,7 @@ index 01ae1c811862f56317a90e3811fe2ef4b593695f..4c9041f1c1cb4b3ec114fbd0c5d4db50
public abstract M copy(); public abstract M copy();
public void copyDataLayer(long pos) { public void copyDataLayer(long pos) {
- this.map.put(pos, ((DataLayer) this.map.get(pos)).copy()); - this.map.put(pos, this.map.get(pos).copy());
+ if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data + if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data
+ this.data.queueUpdate(pos, ((DataLayer) this.data.getUpdating(pos)).copy()); // Paper - avoid copying light data + this.data.queueUpdate(pos, ((DataLayer) this.data.getUpdating(pos)).copy()); // Paper - avoid copying light data
this.clearCache(); this.clearCache();
@ -88,22 +85,22 @@ index 01ae1c811862f56317a90e3811fe2ef4b593695f..4c9041f1c1cb4b3ec114fbd0c5d4db50
- public DataLayer getLayer(long chunkPos) { - public DataLayer getLayer(long chunkPos) {
+ public final DataLayer getLayer(long chunkPos) { // Paper - final + public final DataLayer getLayer(long chunkPos) { // Paper - final
if (this.cacheEnabled) { if (this.cacheEnabled) {
for (int j = 0; j < 2; ++j) { for(int i = 0; i < 2; ++i) {
if (chunkPos == this.lastSectionKeys[j]) { if (chunkPos == this.lastSectionKeys[i]) {
@@ -38,7 +52,7 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> { @@ -38,7 +52,7 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
} }
} }
- DataLayer nibblearray = (DataLayer) this.map.get(chunkPos); - DataLayer dataLayer = this.map.get(chunkPos);
+ DataLayer nibblearray = lookup.apply(chunkPos); // Paper - avoid copying light data + DataLayer dataLayer = lookup.apply(chunkPos); // Paper - avoid copying light data
if (dataLayer == null) {
if (nibblearray == null) {
return null; return null;
@@ -59,11 +73,13 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> { } else {
@@ -58,11 +72,13 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
@Nullable @Nullable
public DataLayer removeLayer(long chunkPos) { public DataLayer removeLayer(long chunkPos) {
- return (DataLayer) this.map.remove(chunkPos); - return this.map.remove(chunkPos);
+ if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data + if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data
+ return (DataLayer) this.data.queueRemove(chunkPos); // Paper - avoid copying light data + return (DataLayer) this.data.queueRemove(chunkPos); // Paper - avoid copying light data
} }
@ -115,45 +112,35 @@ index 01ae1c811862f56317a90e3811fe2ef4b593695f..4c9041f1c1cb4b3ec114fbd0c5d4db50
} }
public void clearCache() { public void clearCache() {
@@ -71,7 +87,6 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
this.lastSectionKeys[i] = Long.MAX_VALUE;
this.lastSections[i] = null;
}
-
}
public void disableCache() {
diff --git a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java diff --git a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java
index 45be10a0d7c26e4b6e5738ba994ce343265210f5..177dae992d13674bb285a60b8427df9ea843dc99 100644 index ee32aba07aad4a3f101a6a57f7aa6c07f74dd0c3..cc9eb8273d5157fb649d84a3ec589b0b923b5bc9 100644
--- a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java --- a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java
+++ b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java +++ b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java
@@ -26,8 +26,8 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>> @@ -28,7 +28,7 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
protected final LongSet dataSectionSet = new LongOpenHashSet(); protected final LongSet dataSectionSet = new LongOpenHashSet();
protected final LongSet toMarkNoData = new LongOpenHashSet(); protected final LongSet toMarkNoData = new LongOpenHashSet();
protected final LongSet toMarkData = new LongOpenHashSet(); protected final LongSet toMarkData = new LongOpenHashSet();
- protected volatile M visibleSectionData; - protected volatile M visibleSectionData;
- protected final M updatingSectionData;
+ protected volatile M e_visible; protected final Object visibleUpdateLock = new Object(); // Paper - diff on change, should be "visible" - force compile fail on usage change + protected volatile M e_visible; protected final Object visibleUpdateLock = new Object(); // Paper - diff on change, should be "visible" - force compile fail on usage change
+ protected final M updatingSectionData; // Paper - diff on change, should be "updating" protected final M updatingSectionData;
protected final LongSet changedSections = new LongOpenHashSet(); protected final LongSet changedSections = new LongOpenHashSet();
protected final LongSet sectionsAffectedByLightUpdates = new LongOpenHashSet(); protected final LongSet sectionsAffectedByLightUpdates = new LongOpenHashSet();
protected final Long2ObjectMap<DataLayer> queuedSections = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap()); @@ -43,8 +43,8 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
@@ -41,8 +41,8 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
this.layer = lightType; this.layer = lightType;
this.chunkSource = chunkProvider; this.chunkSource = chunkProvider;
this.updatingSectionData = lightData; this.updatingSectionData = lightData;
- this.visibleSectionData = lightData.copy(); - this.visibleSectionData = lightData.copy();
- this.visibleSectionData.disableCache(); - this.visibleSectionData.disableCache();
+ this.e_visible = lightData.copy(); // Paper - avoid copying light data + this.e_visible = lightData.copy(); // Paper - avoid copying light dat
+ this.e_visible.disableCache(); // Paper - avoid copying light data + this.e_visible.disableCache(); // Paper - avoid copying light dat
} }
protected boolean storingLightForSection(long sectionPos) { protected boolean storingLightForSection(long sectionPos) {
@@ -51,7 +51,15 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>> @@ -53,7 +53,15 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
@Nullable @Nullable
protected DataLayer getDataLayer(long sectionPos, boolean cached) { protected DataLayer getDataLayer(long sectionPos, boolean cached) {
- return this.getDataLayer(cached ? this.updatingSectionData : this.visibleSectionData, sectionPos); - return this.getDataLayer((M)(cached ? this.updatingSectionData : this.visibleSectionData), sectionPos);
+ // Paper start - avoid copying light data + // Paper start - avoid copying light data
+ if (cached) { + if (cached) {
+ return this.getDataLayer(this.updatingSectionData, sectionPos); + return this.getDataLayer(this.updatingSectionData, sectionPos);
@ -166,150 +153,138 @@ index 45be10a0d7c26e4b6e5738ba994ce343265210f5..177dae992d13674bb285a60b8427df9e
} }
@Nullable @Nullable
@@ -364,10 +372,12 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>> @@ -346,9 +354,11 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
protected void swapSectionMap() { protected void swapSectionMap() {
if (!this.changedSections.isEmpty()) { if (!this.changedSections.isEmpty()) {
+ synchronized (this.visibleUpdateLock) { // Paper - avoid copying light data + synchronized (this.visibleUpdateLock) { // Paper - avoid copying light data
M m0 = this.updatingSectionData.copy(); M dataLayerStorageMap = this.updatingSectionData.copy();
dataLayerStorageMap.disableCache();
m0.disableCache(); - this.visibleSectionData = dataLayerStorageMap;
- this.visibleSectionData = m0; + this.e_visible = dataLayerStorageMap; // Paper - avoid copying light data
+ this.e_visible = m0; // Paper - avoid copying light data
+ } // Paper - avoid copying light data + } // Paper - avoid copying light data
this.changedSections.clear(); this.changedSections.clear();
} }
diff --git a/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java diff --git a/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java
index c304637ae8f80c65b58e8ba8a27609b532bb1184..410fcfa8c01b7e3d3e3829ebdb92a11badff16ea 100644 index fb41fddaee27097b8b503ae13d6a775b207f883a..f6df52403a1068a0779e4ff8c2ce5dc06176e061 100644
--- a/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java --- a/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java
+++ b/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java +++ b/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java
@@ -23,15 +23,16 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec @@ -21,7 +21,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
private volatile boolean hasSourceInconsistencies; private volatile boolean hasSourceInconsistencies;
protected SkyLightSectionStorage(LightChunkGetter chunkProvider) { protected SkyLightSectionStorage(LightChunkGetter chunkProvider) {
- super(LightLayer.SKY, chunkProvider, new SkyLightSectionStorage.SkyDataLayerStorageMap(new Long2ObjectOpenHashMap(), new Long2IntOpenHashMap(), Integer.MAX_VALUE)); - super(LightLayer.SKY, chunkProvider, new SkyLightSectionStorage.SkyDataLayerStorageMap(new Long2ObjectOpenHashMap<>(), new Long2IntOpenHashMap(), Integer.MAX_VALUE));
+ super(LightLayer.SKY, chunkProvider, new SkyLightSectionStorage.SkyDataLayerStorageMap(new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<>(), new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int(), Integer.MAX_VALUE, false)); // Paper - avoid copying light data + super(LightLayer.SKY, chunkProvider, new SkyLightSectionStorage.SkyDataLayerStorageMap(new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<>(), new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int(), Integer.MAX_VALUE, false)); // Paper - avoid copying light data
} }
@Override @Override
protected int getLightValue(long blockPos) { @@ -32,8 +32,9 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
long j = SectionPos.blockToSection(blockPos); protected int getLightValue(long l, boolean bl) {
int k = SectionPos.y(j); long m = SectionPos.blockToSection(l);
- SkyLightSectionStorage.SkyDataLayerStorageMap lightenginestoragesky_a = (SkyLightSectionStorage.SkyDataLayerStorageMap) this.visibleSectionData; int i = SectionPos.y(m);
- int l = lightenginestoragesky_a.topSections.get(SectionPos.getZeroNode(j)); - SkyLightSectionStorage.SkyDataLayerStorageMap skyDataLayerStorageMap = bl ? this.updatingSectionData : this.visibleSectionData;
- int j = skyDataLayerStorageMap.topSections.get(SectionPos.getZeroNode(m));
+ synchronized (this.visibleUpdateLock) { // Paper - avoid copying light data + synchronized (this.visibleUpdateLock) { // Paper - avoid copying light data
+ SkyLightSectionStorage.SkyDataLayerStorageMap lightenginestoragesky_a = (SkyLightSectionStorage.SkyDataLayerStorageMap) this.e_visible; // Paper - avoid copying light data - must be after lock acquire + SkyLightSectionStorage.SkyDataLayerStorageMap skyDataLayerStorageMap = (SkyLightSectionStorage.SkyDataLayerStorageMap) this.e_visible; // Paper - avoid copying light data - must be after lock acquire
+ int l = lightenginestoragesky_a.otherData.getVisibleAsync(SectionPos.getZeroNode(j)); // Paper - avoid copying light data + int j = skyDataLayerStorageMap.otherData.getVisibleAsync(SectionPos.getZeroNode(m)); // Paper - avoid copying light data
if (j != skyDataLayerStorageMap.currentLowestY && i < j) {
if (l != lightenginestoragesky_a.currentLowestY && k < l) { DataLayer dataLayer = this.getDataLayer(skyDataLayerStorageMap, m);
DataLayer nibblearray = this.getDataLayer(lightenginestoragesky_a, j); // Paper - decompile fix if (dataLayer == null) {
@@ -52,6 +53,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec @@ -52,6 +53,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
} else { } else {
return 15; return bl && !this.lightOnInSection(m) ? 0 : 15;
} }
+ } // Paper - avoid copying light data + } // Paper - avoid copying light data
} }
@Override @Override
@@ -60,14 +62,14 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec @@ -59,13 +61,13 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
int i = SectionPos.y(sectionPos);
if (((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY > j) { if ((this.updatingSectionData).currentLowestY > i) {
((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY = j; (this.updatingSectionData).currentLowestY = i;
- ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.defaultReturnValue(((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY); - (this.updatingSectionData).topSections.defaultReturnValue((this.updatingSectionData).currentLowestY);
+ ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.queueDefaultReturnValue(((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY); // Paper - avoid copying light data + (this.updatingSectionData).otherData.queueDefaultReturnValue((this.updatingSectionData).currentLowestY); // Paper - avoid copying light data
} }
long k = SectionPos.getZeroNode(sectionPos); long l = SectionPos.getZeroNode(sectionPos);
- int l = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.get(k); - int j = (this.updatingSectionData).topSections.get(l);
+ int l = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.getUpdating(k); // Paper - avoid copying light data + int j = (this.updatingSectionData).otherData.getUpdating(l); // Paper - avoid copying light data
if (j < i + 1) {
if (l < j + 1) { - (this.updatingSectionData).topSections.put(l, i + 1);
- ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.put(k, j + 1); + (this.updatingSectionData).otherData.queueUpdate(l, i + 1); // Paper - avoid copying light data
+ ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.queueUpdate(k, j + 1); // Paper - avoid copying light data if (this.columnsWithSkySources.contains(l)) {
if (this.columnsWithSkySources.contains(k)) {
this.queueAddSource(sectionPos); this.queueAddSource(sectionPos);
if (l > ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY) { if (j > (this.updatingSectionData).currentLowestY) {
@@ -107,7 +109,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec @@ -102,19 +104,19 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
int k = SectionPos.y(sectionPos);
- if (((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.get(j) == k + 1) {
+ if (((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.getUpdating(j) == k + 1) { // Paper - avoid copying light data
long l;
for (l = sectionPos; !this.storingLightForSection(l) && this.hasSectionsBelow(k); l = SectionPos.offset(l, Direction.DOWN)) {
@@ -115,12 +117,12 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
} }
if (this.storingLightForSection(l)) { int i = SectionPos.y(sectionPos);
- ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.put(j, k + 1); - if ((this.updatingSectionData).topSections.get(l) == i + 1) {
+ ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.queueUpdate(j, k + 1); // Paper - avoid copying light data + if ((this.updatingSectionData).otherData.getUpdating(l) == i + 1) { // Paper - avoid copying light data
if (flag) { long m;
this.queueAddSource(l); for(m = sectionPos; !this.storingLightForSection(m) && this.hasSectionsBelow(i); m = SectionPos.offset(m, Direction.DOWN)) {
--i;
}
if (this.storingLightForSection(m)) {
- (this.updatingSectionData).topSections.put(l, i + 1);
+ (this.updatingSectionData).otherData.queueUpdate(l, i + 1); // Paper - avoid copying light data
if (bl) {
this.queueAddSource(m);
} }
} else { } else {
- ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.remove(j); - (this.updatingSectionData).topSections.remove(l);
+ ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.queueRemove(j); // Paper - avoid copying light data + (this.updatingSectionData).otherData.queueRemove(l); // Paper - avoid copying light data
} }
} }
@@ -134,7 +136,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec @@ -128,7 +130,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
protected void enableLightSources(long columnPos, boolean enabled) { protected void enableLightSources(long columnPos, boolean enabled) {
this.runAllUpdates(); this.runAllUpdates();
if (enabled && this.columnsWithSkySources.add(columnPos)) { if (enabled && this.columnsWithSkySources.add(columnPos)) {
- int j = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.get(columnPos); - int i = (this.updatingSectionData).topSections.get(columnPos);
+ int j = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.getUpdating(columnPos); // Paper - avoid copying light data + int i = (this.updatingSectionData).otherData.getUpdating(columnPos); // Paper - avoid copying light data
if (i != (this.updatingSectionData).currentLowestY) {
if (j != ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY) { long l = SectionPos.asLong(SectionPos.x(columnPos), i - 1, SectionPos.z(columnPos));
long k = SectionPos.asLong(SectionPos.x(columnPos), j - 1, SectionPos.z(columnPos)); this.queueAddSource(l);
@@ -161,7 +163,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec @@ -152,7 +154,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
return nibblearray; return dataLayer;
} else { } else {
long j = SectionPos.offset(sectionPos, Direction.UP); long l = SectionPos.offset(sectionPos, Direction.UP);
- int k = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.get(SectionPos.getZeroNode(sectionPos)); - int i = (this.updatingSectionData).topSections.get(SectionPos.getZeroNode(sectionPos));
+ int k = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.getUpdating(SectionPos.getZeroNode(sectionPos)); // Paper - avoid copying light data + int i = (this.updatingSectionData).otherData.getUpdating(SectionPos.getZeroNode(sectionPos)); // Paper - avoid copying light data
if (i != (this.updatingSectionData).currentLowestY && SectionPos.y(l) < i) {
if (k != ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY && SectionPos.y(j) < k) { DataLayer dataLayer2;
DataLayer nibblearray1; while((dataLayer2 = this.getDataLayer(l, true)) == null) {
@@ -304,7 +306,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec @@ -260,7 +262,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
if (!this.columnsWithSkySources.contains(l)) {
return false;
} else {
- int i1 = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.get(l);
+ int i1 = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.getUpdating(l); // Paper - avoid copying light data
return SectionPos.sectionToBlockCoord(i1) == j + 16;
}
@@ -313,7 +315,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
protected boolean isAboveData(long sectionPos) { protected boolean isAboveData(long sectionPos) {
long j = SectionPos.getZeroNode(sectionPos); long l = SectionPos.getZeroNode(sectionPos);
- int k = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).topSections.get(j); - int i = (this.updatingSectionData).topSections.get(l);
+ int k = ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).otherData.getUpdating(j); // Paper - avoid copying light data + int i = (this.updatingSectionData).otherData.getUpdating(l); // Paper - avoid copying light data
return i == (this.updatingSectionData).currentLowestY || SectionPos.y(sectionPos) >= i;
return k == ((SkyLightSectionStorage.SkyDataLayerStorageMap) this.updatingSectionData).currentLowestY || SectionPos.y(sectionPos) >= k;
} }
@@ -327,18 +329,21 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
public static final class SkyDataLayerStorageMap extends DataLayerStorageMap<SkyLightSectionStorage.SkyDataLayerStorageMap> {
private int currentLowestY; @@ -271,18 +273,21 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
- private final Long2IntOpenHashMap topSections;
protected static final class SkyDataLayerStorageMap extends DataLayerStorageMap<SkyLightSectionStorage.SkyDataLayerStorageMap> {
int currentLowestY;
- final Long2IntOpenHashMap topSections;
- -
- public SkyDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays, Long2IntOpenHashMap columnToTopSection, int minSectionY) { - public SkyDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays, Long2IntOpenHashMap columnToTopSection, int minSectionY) {
- super(arrays); - super(arrays);
- this.topSections = columnToTopSection; - this.topSections = columnToTopSection;
- columnToTopSection.defaultReturnValue(minSectionY); - columnToTopSection.defaultReturnValue(minSectionY);
- this.currentLowestY = minSectionY;
+ private final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData; // Paper - avoid copying light data + private final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData; // Paper - avoid copying light data
+ +
+ // Paper start - avoid copying light data + // Paper start - avoid copying light data
+ public SkyDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> data, com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData, int i, boolean isVisible) { + public SkyDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> arrays, com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int columnToTopSection, int minSectionY, boolean isVisible) {
+ super(data, isVisible); + super(arrays, isVisible);
+ this.otherData = otherData; + this.otherData = columnToTopSection;
+ otherData.queueDefaultReturnValue(i); + otherData.queueDefaultReturnValue(minSectionY);
+ // Paper end - avoid copying light data + // Paper end
+ this.currentLowestY = i; this.currentLowestY = minSectionY;
} }
@Override @Override

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add zombie targets turtle egg config
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 040956f5d714ac014f9a153981d444db299fd826..83a4a3bbea1c076788cb7746adcee61e128b90fe 100644 index a22abda177b0ffc9699fb23aaac8680261f385fe..a14989c20275c49b0e6eaba52f3e06b28b043445 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -38,6 +38,11 @@ public class PaperWorldConfig { @@ -38,6 +38,11 @@ public class PaperWorldConfig {

View File

@ -19,7 +19,7 @@ Aside from making the obvious class/function renames and obfhelpers I didn't nee
Just added Bukkit's event system and took a few liberties with dead code and comment misspellings. Just added Bukkit's event system and took a few liberties with dead code and comment misspellings.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 83a4a3bbea1c076788cb7746adcee61e128b90fe..acbaa00167d60ca6c6019b2dcd0947ef1d0557ee 100644 index a14989c20275c49b0e6eaba52f3e06b28b043445..631b68a4a661ceadac02c032e9199c54580f4079 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -43,6 +43,16 @@ public class PaperWorldConfig { @@ -43,6 +43,16 @@ public class PaperWorldConfig {

View File

@ -10,7 +10,7 @@ In general, look at making this logic more robust (i.e properly handling
cases where a captured entry is overriden) - but for now this will do. cases where a captured entry is overriden) - but for now this will do.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index f004f5012ce157f9b0fb9c5890b5f3de957418f8..febc4fececb4bf527a69e47a06d782ec81616c1e 100644 index d9697003d05ddc344207793b4f266743fcaef16c..c820cc7f3be693f445937a157ac2477e36f906b4 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -147,7 +147,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -147,7 +147,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Toggle for removing existing dragon
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index acbaa00167d60ca6c6019b2dcd0947ef1d0557ee..b3e9149dbbc1cd6a6d01bb9f7109136b995afb0a 100644 index 631b68a4a661ceadac02c032e9199c54580f4079..f46890906f324d8c3f4d1917d38b0f8f8604e2f2 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -53,6 +53,14 @@ public class PaperWorldConfig { @@ -53,6 +53,14 @@ public class PaperWorldConfig {

View File

@ -21,7 +21,7 @@ changes but this should usually not happen. A config option to disable
this completely is added though in case that should ever be necessary. this completely is added though in case that should ever be necessary.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index b3e9149dbbc1cd6a6d01bb9f7109136b995afb0a..2523aabf499ef3807af02f7e61a3b13dbca08ee3 100644 index f46890906f324d8c3f4d1917d38b0f8f8604e2f2..72bfeb3d465585ea6de4e896eee65b5bed75188d 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -376,6 +376,14 @@ public class PaperWorldConfig { @@ -376,6 +376,14 @@ public class PaperWorldConfig {

View File

@ -11,7 +11,7 @@ in IWorldServerData are removed as they were only used in certain places, with h
values used in other places. values used in other places.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 2523aabf499ef3807af02f7e61a3b13dbca08ee3..d76b292cdfa2ae4d84a449da7f66faba494f6b03 100644 index 72bfeb3d465585ea6de4e896eee65b5bed75188d..19c42a9863341f1d06ad57e95049b3cd5b88aeb2 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -61,6 +61,19 @@ public class PaperWorldConfig { @@ -61,6 +61,19 @@ public class PaperWorldConfig {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Climbing should not bypass cramming gamerule
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index d76b292cdfa2ae4d84a449da7f66faba494f6b03..0ec093e5d8865e909d0d105e27b81b31bdb5c192 100644 index 19c42a9863341f1d06ad57e95049b3cd5b88aeb2..aef38974128c7986864571a3552a566ad672dccd 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -74,6 +74,11 @@ public class PaperWorldConfig { @@ -74,6 +74,11 @@ public class PaperWorldConfig {

View File

@ -8,7 +8,7 @@ and curing a villager on repeat by simply resetting the relevant part of
the reputation when it is cured. the reputation when it is cured.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 0ec093e5d8865e909d0d105e27b81b31bdb5c192..1a8e7a495c38f617932825185378b2e494158175 100644 index aef38974128c7986864571a3552a566ad672dccd..dd23c6dc5e680006c10329433c059fc9b85dd1cc 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -79,6 +79,11 @@ public class PaperWorldConfig { @@ -79,6 +79,11 @@ public class PaperWorldConfig {

Some files were not shown because too many files have changed in this diff Show More