Foundational work for Future Memory usage improvements

This commit doesn't do much on its own, but adds a new Java Cleaner API
that lets us hook into Garbage Collector events to reclaim pooled objects and
return them to the pool.

Adds framework for Network Packets to know when a packet has finished dispatching
to get an idea when a packet is done sending to players.

Rewrites PooledObjects impl to properly respect max pool size and remove
almost all risk of contention.

Bumps the Paper Async Task Queue to use 2 threads, and properly shuts it down on shutdown.
This commit is contained in:
Aikar
2020-05-16 21:38:19 -04:00
parent bb4002d82e
commit 897dd2c840
30 changed files with 395 additions and 274 deletions

View File

@@ -198,7 +198,7 @@ index 8c6550433c20c54cbe390219821ce393c5720da8..e6d08756f76360b29b29f18305e5ec84
public final ChunkGenerator<?> chunkGenerator;
private final WorldServer world;
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index 3342278bcd42a6d5a1793e33bc7fe4356be02451..2dcecc1bbd00e46b0a9b5e48bc580475fc8b4cb3 100644
index be20d770df41a656cf2aabfec87e0bdc639053f4..de8b8f54cd906c1154a6790b9220d3e0976c74bd 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -4,7 +4,13 @@ import com.destroystokyo.paper.block.TargetBlockInfo;
@@ -226,8 +226,8 @@ index 3342278bcd42a6d5a1793e33bc7fe4356be02451..2dcecc1bbd00e46b0a9b5e48bc580475
+import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
@@ -452,4 +461,170 @@ public final class MCUtil {
import java.util.concurrent.LinkedBlockingQueue;
@@ -511,4 +520,170 @@ public final class MCUtil {
return null;
}