-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* uwu * reorder * Change author * Sync upstream * Lithium: equipment tracking * Faster CraftServer#getworlds list creation Co-Authored-By: Kobe ⑧ <102713261+HaHaWTH@users.noreply.github.com>
- Loading branch information
1 parent
fa9c4a7
commit 27134f6
Showing
52 changed files
with
844 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Taiyou06 <kaandindar21@gmail.com> | ||
Date: Tue, 9 Nov 2077 00:00:00 +0800 | ||
Subject: [PATCH] Remove stream in GateBehavior | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java | ||
index d4581127366736c54f74e4ef7479236b18fb487d..67aa59deebdf47e53d9f6949b26c9b313de45035 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java | ||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java | ||
@@ -73,9 +73,20 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> | ||
} | ||
} | ||
// Paper end - Perf: Remove streams from hot code | ||
- if (this.behaviors.stream().noneMatch(task -> task.getStatus() == Behavior.Status.RUNNING)) { | ||
+ | ||
+ // Leaf start - Remove more streams in GateBehavior | ||
+ boolean hasRunningTask = false; | ||
+ for (final BehaviorControl<? super E> task : this.behaviors) { | ||
+ if (task.getStatus() == Behavior.Status.RUNNING) { | ||
+ hasRunningTask = true; | ||
+ break; | ||
+ } | ||
+ } | ||
+ | ||
+ if (!hasRunningTask) { | ||
this.doStop(world, entity, time); | ||
} | ||
+ // Leaf end - Remove more streams in GateBehavior | ||
} | ||
|
||
@Override |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
patches/server/0151-Collect-then-startEachNonRunningBehavior-in-Brain.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Taiyou06 <kaandindar21@gmail.com> | ||
Date: Tue, 9 Nov 2077 00:00:00 +0800 | ||
Subject: [PATCH] Collect then startEachNonRunningBehavior in Brain | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/entity/ai/Brain.java b/src/main/java/net/minecraft/world/entity/ai/Brain.java | ||
index 65bd8c2cccd0a4a68984ea8ff4cd3cf365330630..aeb74b96704e0f187178e2ae106e0a3f6d95717c 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/ai/Brain.java | ||
+++ b/src/main/java/net/minecraft/world/entity/ai/Brain.java | ||
@@ -466,20 +466,30 @@ public class Brain<E extends LivingEntity> { | ||
} | ||
|
||
private void startEachNonRunningBehavior(ServerLevel world, E entity) { | ||
- long l = world.getGameTime(); | ||
+ // Leaf start - Collect first then start | ||
+ final long gameTime = world.getGameTime(); | ||
|
||
- for (Map<Activity, Set<BehaviorControl<? super E>>> map : this.availableBehaviorsByPriority.values()) { | ||
- for (Entry<Activity, Set<BehaviorControl<? super E>>> entry : map.entrySet()) { | ||
- Activity activity = entry.getKey(); | ||
- if (this.activeActivities.contains(activity)) { | ||
- for (BehaviorControl<? super E> behaviorControl : entry.getValue()) { | ||
- if (behaviorControl.getStatus() == Behavior.Status.STOPPED) { | ||
- behaviorControl.tryStart(world, entity, l); | ||
+ List<BehaviorControl<? super E>> behaviorsToStart = new ObjectArrayList<>(); | ||
+ | ||
+ for (Activity activeActivity : this.activeActivities) { | ||
+ for (Map<Activity, Set<BehaviorControl<? super E>>> priorityMap : this.availableBehaviorsByPriority.values()) { | ||
+ Set<BehaviorControl<? super E>> behaviors = priorityMap.get(activeActivity); | ||
+ | ||
+ if (behaviors != null && !behaviors.isEmpty()) { | ||
+ for (BehaviorControl<? super E> behavior : behaviors) { | ||
+ if (behavior.getStatus() == Behavior.Status.STOPPED) { | ||
+ behaviorsToStart.add(behavior); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
+ if (!behaviorsToStart.isEmpty()) { | ||
+ for (BehaviorControl<? super E> behavior : behaviorsToStart) { | ||
+ behavior.tryStart(world, entity, gameTime); | ||
+ } | ||
+ } | ||
+ // Leaf end - Collect first then start | ||
} | ||
|
||
private void tickEachRunningBehavior(ServerLevel world, E entity) { |
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
patches/server/0153-Faster-CraftServer-getworlds-list-creation.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> | ||
Date: Tue, 9 Nov 2077 00:00:00 +0800 | ||
Subject: [PATCH] Faster CraftServer#getworlds list creation | ||
|
||
CraftServer#getWorlds/Bukkit#getWorlds is frequently used in plugins, | ||
replacing ArrayList with Fastutil ObjectArrayList | ||
brings about 40% performance improvement in benchmark. | ||
|
||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java | ||
index 5f4e5b386047258948a0c8772d93bfa8be734ffc..c7d806f7e2ddef2226be1efbe794f0da4c331615 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java | ||
@@ -976,7 +976,7 @@ public final class CraftServer implements Server { | ||
|
||
@Override | ||
public List<World> getWorlds() { | ||
- return new ArrayList<World>(this.worlds.values()); | ||
+ return new it.unimi.dsi.fastutil.objects.ObjectArrayList<World>(this.worlds.values()); // Leaf - Faster CraftServer#getWorlds list creation | ||
} | ||
|
||
@Override |