Skip to content

Commit

Permalink
Update Paper and add configurable region shift
Browse files Browse the repository at this point in the history
The region shift is configurable under `grid-exponent`, which
allows setting the region shift to any value in [0, 31]. Note
that values above 6 affect the lock shift, as the lock shift
currently is computed as max(ticket shift = 6, region shift).
The shift is left configurable for now as the lower default
shift of 2 may have negative performance impacts.

The default region shift has been adjusted to 2 from 4, and
the empty chunk buffer has been reduced to 8 from 16. These
changes reduce, but do not eliminate, player spread
requirements. The previous block range was around ~1500 blocks
at VD = 10, but is now closer to ~900 blocks at VD = 10. This
roughly reduces the area that each player uses in the regioniser
by 2.5x.
  • Loading branch information
Spottedleaf committed Dec 31, 2023
1 parent 9a389a1 commit 6928284
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 380 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group=dev.folia

version=1.20.4-R0.1-SNAPSHOT
mcVersion=1.20.4
paperRef=1e7dd72f15a1d13b43792367193547c656a16ab6
paperRef=1281f4f5526c0b8bdc32915c41dc6af6b4f9fea2

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
12 changes: 6 additions & 6 deletions patches/server/0001-Build-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Subject: [PATCH] Build changes


diff --git a/build.gradle.kts b/build.gradle.kts
index b12b5a1e82a5ebf47135a3863a390a45a9d8d8ec..03abea227c555decd559dd58b33913127f3549a4 100644
index 58da26ad2f128ba0b66f86820f60853f4be352f0..38352926640d97449256d50ebdec619ce9e695a0 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -27,8 +27,12 @@ repositories {
@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
val alsoShade: Configuration by configurations.creating

dependencies {
extraRuntime(platform("net.kyori:adventure-bom:4.15.0-SNAPSHOT"))
- implementation(project(":paper-api"))
- implementation(project(":paper-mojangapi"))
+ // Folia start
Expand All @@ -23,7 +23,7 @@ index b12b5a1e82a5ebf47135a3863a390a45a9d8d8ec..03abea227c555decd559dd58b3391312
// Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -84,7 +88,7 @@ tasks.jar {
@@ -70,7 +74,7 @@ tasks.jar {
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
"Implementation-Title" to "CraftBukkit",
Expand All @@ -32,7 +32,7 @@ index b12b5a1e82a5ebf47135a3863a390a45a9d8d8ec..03abea227c555decd559dd58b3391312
"Implementation-Vendor" to date, // Paper
"Specification-Title" to "Bukkit",
"Specification-Version" to project.version,
@@ -168,7 +172,7 @@ fun TaskContainer.registerRunTask(
@@ -154,7 +158,7 @@ fun TaskContainer.registerRunTask(
name: String,
block: JavaExec.() -> Unit
): TaskProvider<JavaExec> = register<JavaExec>(name) {
Expand Down Expand Up @@ -106,7 +106,7 @@ index 34f19ac897a30c0c4e3ab406013fcca1c8b7db93..5ed6c8710b78458031ed6b0273fb2f6a

public SystemReport fillSystemReport(SystemReport details) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e011cfcdda2e0a609d4158b0454bdf046b04c9d9..3e7b9561dd69b634149181be7a537d0546ceb233 100644
index 142d2c48239d4ebe3896218536656d116cd24d7c..d0bddf66a8cbf1cd1348cc40ef8bbc125b7483ed 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -264,7 +264,7 @@ import javax.annotation.Nullable; // Paper
Expand Down
656 changes: 328 additions & 328 deletions patches/server/0003-Threaded-Regions.patch

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions patches/server/0004-Max-pending-logins.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Max pending logins
Should help the floodgates on launch

diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 54aa8ac790f7d23d6404d037105642ddddb7839b..c18fc39db6480f0942128a5512970fdce074b7c6 100644
index 5834d5e10c0b9892f29977666e7b168a9463a3d9..5bac302f6aab2c61cba87ea3e32a260eeb0284b4 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -89,7 +89,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
Expand All @@ -19,7 +19,7 @@ index 54aa8ac790f7d23d6404d037105642ddddb7839b..c18fc39db6480f0942128a5512970fdc

if (this.state == ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT && !this.isPlayerAlreadyInWorld((GameProfile) Objects.requireNonNull(this.authenticatedProfile))) {
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 0fa69640a699e1c33cb307366b0335ac9bac4282..bc31d4dfd6fca354c093f552901a59e5b83c92d7 100644
index 184057aae74e8918bf05ab03429cb0419ae9ba06..eb797313a13b5a805f834b2e9f08989e381f0761 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -171,6 +171,17 @@ public abstract class PlayerList {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ index d657fd2c507a5b215aeab0a5f3e9c2ee892a27c8..9fc90b162aab15a9cd60b02aba563181
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 9a4a7bae17dd554aeeffb0ec4cb0876ef797e097..a47939461fcf3ba9aabcf66d1db9738b9785314a 100644
index 56c7eda0dbfbb8987e1e642936b46e2a320466f7..b3faadd991f6885bfcaf4fd6fa895889670a1bb2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -490,7 +490,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
Expand Down Expand Up @@ -1590,10 +1590,10 @@ index 70b377c03346cb8573827aeb493f3b6eb8efb1f8..b2e8c26162dd5782a0447cd03ca00fb4
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 25ffc92c3d6055285a64d9fe36c0054228fe81dd..f2360767907480b64fd51ac3156932b9bf8ee609 100644
index 1f1ef68a9a449a4a90c284f34a397ab4b6d905f6..9da62ca03e60c8cbe4714c7056c7642cce2c0b9e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -417,6 +417,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@@ -416,6 +416,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
this.getHandle().invulnerableTime = ticks;
}

Expand All @@ -1607,7 +1607,7 @@ index 25ffc92c3d6055285a64d9fe36c0054228fe81dd..f2360767907480b64fd51ac3156932b9
@Override
public int getNoActionTicks() {
return this.getHandle().getNoActionTime();
@@ -430,6 +437,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@@ -429,6 +436,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {

@Override
public net.minecraft.world.entity.LivingEntity getHandle() {
Expand Down Expand Up @@ -2130,7 +2130,7 @@ index 2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf..0f5c2d31a2dea13a46ba81e353393633
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0566674223e16e34eaa4ab1d21e0e060bd0aeee5..fca4f9a50e57a2b40c7bca92d975b72da1075fa3 100644
index 5a7263da8e82e45c616e6cbf227929813028b136..a288ed0640bfe852677294398474510ab578577a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -616,7 +616,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Expand All @@ -2142,7 +2142,7 @@ index 0566674223e16e34eaa4ab1d21e0e060bd0aeee5..fca4f9a50e57a2b40c7bca92d975b72d
final ServerGamePacketListenerImpl connection = this.getHandle().connection;
if (connection != null) {
connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause);
@@ -2159,9 +2159,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2200,9 +2200,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return this;
}

Expand All @@ -2160,7 +2160,7 @@ index 0566674223e16e34eaa4ab1d21e0e060bd0aeee5..fca4f9a50e57a2b40c7bca92d975b72d
}

public void setHandle(final ServerPlayer entity) {
@@ -3172,7 +3179,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -3236,7 +3243,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
{
if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Throw UnsupportedOperationException() for broken APIs


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6e2bbd699d9b168ee9eb89461d588701c0511a24..bea388ced64da6192166f6f8461abdc0921ed7b0 100644
index bfa318486443c61c3734046331fdfeecf9852591..7d1be59d03fa4e46295bc91943fea16bd9c7c802 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1264,6 +1264,7 @@ public final class CraftServer implements Server {
Expand All @@ -25,7 +25,7 @@ index 6e2bbd699d9b168ee9eb89461d588701c0511a24..bea388ced64da6192166f6f8461abdc0
if (world == null) {
return false;
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
index bd8a5bb2b84daf013750aec9887dcb4b02b382ad..299e7290fea260d739687be70a796c5a4add325b 100644
index e7d3637927e92c181ecc2e21a3456918afb30822..942c2dafbf2b6a0df8415fa9c09747ed313ee209 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
@@ -45,6 +45,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ add explicit block update suppression techniques, it's better
than the server crashing.

diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 91f17ee2b6c9e1413b5bef62adcfe2a0d9537fef..474757fe16986d84f84302a22441c332d622d038 100644
index 48480686e8f1a554818e58890f9a8f3f4afd0a43..b924986c4e3b9e20a4100481c5d6534b040950af 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1764,7 +1764,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1758,7 +1758,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
Direction enumdirection = (Direction) iterator.next();
BlockPos blockposition1 = pos.relative(enumdirection);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data deserialization and is racey even in Vanilla. But in Folia,
some accesses may throw and as such we need to fix this directly.

diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 08176ffc089fd20f64f98690d0f383f6d91aaf53..0b27e7ffdc6b61b8e64afc253a8470c1ad8791dd 100644
index e479129a977721fc8061be968eefab4daa407f5c..3d2b059254fdc08d1e4f9281946028a46884d7c8 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -644,7 +644,7 @@ public class ServerPlayer extends Player {
Expand All @@ -22,7 +22,7 @@ index 08176ffc089fd20f64f98690d0f383f6d91aaf53..0b27e7ffdc6b61b8e64afc253a8470c1

// CraftBukkit start
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index d74c6ee198daa125d78cd815e1e0d1f7194caeac..15e441ba4d5286e7bf677f7c0ad5fb8f62437d72 100644
index 46b835f65ec64720efa54cc524f16a3fa536e90b..abf455d165004240e0b5fd96543f7da7c520e729 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4360,6 +4360,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This allows the player to be re-positioned before logging into
the world without causing thread checks to trip on Folia.

diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index bc31d4dfd6fca354c093f552901a59e5b83c92d7..72c32a9b4b0606162a0f994b3d8170f0fe4d5022 100644
index eb797313a13b5a805f834b2e9f08989e381f0761..e63ad8ed0318fb99e99a8609ef6a31d16f87e7ff 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -514,7 +514,13 @@ public abstract class PlayerList {
Expand Down
Loading

1 comment on commit 6928284

@Milireso
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reducing the required player spread is a great direction in my opinion! Previously single wandering player would connect regions and cause lag for them from time to time.
Does it have to be based on view distance though? The ticked simulation distance is set lower than view on almost all servers. If players were able to see further, they would feel less restricted and more encouraged to build. This is especially noticable on recent minecraft versions with huge mountains and valleys.
Even with VD = 16 and two players being 900 blocks apart, there are full 24 unrendered chunks between them. And with SD = 10 full 36 chunks do not have to be ticked.

Please sign in to comment.