9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-24 01:09:29 +00:00

Optimize CraftServer.getWorld(UUID); Pufferfish SIMD Java Version

This commit is contained in:
NONPLAYT
2024-01-13 14:05:54 +03:00
parent 4f2c4da317
commit 44b71fe1b6
3 changed files with 103 additions and 1 deletions

View File

@@ -137,8 +137,39 @@ index 3cb56595822799926a8141e60a42f5d1edfc6de5..05478a1ea04ec0396bc8c97090edef4a
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
.completer(new ConsoleCommandCompleter(this.server))
.option(LineReader.Option.COMPLETE_IN_WORD, true);
diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
index 64e12201e164f4dc8070711605dcfcb6e56421f6..ad5c7d2f133834fd587ab0b8b5835313b52e6fa2 100644
--- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
+++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
@@ -56,7 +56,7 @@ public class MinecraftServerGui extends JComponent {
;
}
- final JFrame jframe = new JFrame("Purpur Minecraft server"); // Purpur
+ final JFrame jframe = new JFrame("DivineMC Minecraft server"); // Purpur // DivineMC
final MinecraftServerGui servergui = new MinecraftServerGui(server);
jframe.setDefaultCloseOperation(2);
@@ -64,7 +64,7 @@ public class MinecraftServerGui extends JComponent {
jframe.pack();
jframe.setLocationRelativeTo((Component) null);
jframe.setVisible(true);
- jframe.setName("Purpur Minecraft server"); // Paper // Purpur
+ jframe.setName("DivineMC Minecraft server"); // Paper // Purpur // DivineMC
// Paper start - Add logo as frame image
try {
@@ -76,7 +76,7 @@ public class MinecraftServerGui extends JComponent {
jframe.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowevent) {
if (!servergui.isClosing.getAndSet(true)) {
- jframe.setTitle("Purpur Minecraft server - shutting down!"); // Purpur
+ jframe.setTitle("DivineMC Minecraft server - shutting down!"); // Purpur // DivineMC
server.halt(true);
servergui.runFinalizers();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index aef22db014c81332ba599ddb931afb264dc12a84..19fca5427c175a1ebcfb6c37c9ce91a51b285c0f 100644
index aa04387019f2aef5e7e54a9654c05f832d508295..08808e9d98380792b4d4c944b7b1723a3efb346d 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

View File

@@ -0,0 +1,52 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 13 Jan 2024 13:36:55 +0300
Subject: [PATCH] Optimize CraftServer.getWorld(UUID)
Original code by MultiPaper - https://github.com/MultiPaper/MultiPaper
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c5c5731a755fe635384aad24c3ac5152e5c8ae74..7143fcce199b6cbccb8ae40d942f5e7b7483c9a6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -264,6 +264,8 @@ import net.md_5.bungee.api.chat.BaseComponent; // Spigot
import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // DivineMC
+
public final class CraftServer implements Server {
private final String serverName = "DivineMC"; // Paper // Pufferfish // Purpur // DivineMC
private final String serverVersion;
@@ -280,6 +282,7 @@ public final class CraftServer implements Server {
protected final DedicatedServer console;
protected final DedicatedPlayerList playerList;
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
+ private final Map<UUID, World> worldsByUUID = new Object2ObjectLinkedOpenHashMap<>(); // DivineMC - MultiPaper - optimize getWorld(UUID)
private final Map<Class<?>, Registry<?>> registries = new HashMap<>();
private YamlConfiguration configuration;
private YamlConfiguration commandsConfiguration;
@@ -1466,6 +1469,7 @@ public final class CraftServer implements Server {
this.getLogger().log(Level.SEVERE, null, ex);
}
+ this.worldsByUUID.remove(world.getUID()); // DivineMC - MultiPaper - optimize getWorld(UUID)
this.worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH));
this.console.removeLevel(handle);
return true;
@@ -1484,6 +1488,7 @@ public final class CraftServer implements Server {
@Override
public World getWorld(UUID uid) {
+ if (true) return this.worldsByUUID.get(uid); // DivineMC - MultiPaper - optimize getWorld(UUID)
for (World world : this.worlds.values()) {
if (world.getUID().equals(uid)) {
return world;
@@ -1507,6 +1512,7 @@ public final class CraftServer implements Server {
System.out.println("World " + world.getName() + " is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from " + world.getName() + "'s world directory if you want to be able to load the duplicate world.");
return;
}
+ this.worldsByUUID.put(world.getUID(), world); // DivineMC - MultiPaper - optimize getWorld(UUID)
this.worlds.put(world.getName().toLowerCase(java.util.Locale.ENGLISH), world);
}

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 13 Jan 2024 13:41:03 +0300
Subject: [PATCH] Add Higher Java Version for Pufferfish SIMD
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
index b4e5fbace85c67e7bd347e6a90514bbc2c132d5e..b098c2fd656e8f86683083b5628eed586ae88ad6 100644
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
@@ -87,7 +87,7 @@ public class PufferfishConfig {
// Attempt to detect vectorization
try {
SIMDDetection.isEnabled = SIMDDetection.canEnable(PufferfishLogger.LOGGER);
- SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19;
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17; // DivineMC - Add Higher Java Version for Pufferfish SIMD
} catch (NoClassDefFoundError | Exception ignored) {
ignored.printStackTrace();
}