diff --git a/src/main/java/me/jellysquid/mods/lithium/common/config/LithiumConfig.java b/src/main/java/me/jellysquid/mods/lithium/common/config/LithiumConfig.java index 35c08d71d..71ce44c85 100644 --- a/src/main/java/me/jellysquid/mods/lithium/common/config/LithiumConfig.java +++ b/src/main/java/me/jellysquid/mods/lithium/common/config/LithiumConfig.java @@ -122,7 +122,6 @@ private LithiumConfig() { this.addMixinRule("world.block_entity_ticking", true); this.addMixinRule("world.block_entity_ticking.support_cache", false); //have to check whether the cached state bugfix fixes any detectable vanilla bugs first this.addMixinRule("world.chunk_access", true); - this.addMixinRule("world.chunk_task_system", true); this.addMixinRule("world.chunk_tickets", true); this.addMixinRule("world.chunk_ticking", false); //removed during 1.18 update this.addMixinRule("world.explosions", true); diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/thread/ArrayPrioritizedTaskQueue.java b/src/main/java/me/jellysquid/mods/lithium/common/util/thread/ArrayPrioritizedTaskQueue.java deleted file mode 100644 index d50acb3de..000000000 --- a/src/main/java/me/jellysquid/mods/lithium/common/util/thread/ArrayPrioritizedTaskQueue.java +++ /dev/null @@ -1,66 +0,0 @@ -package me.jellysquid.mods.lithium.common.util.thread; - -import com.google.common.collect.Queues; -import net.minecraft.util.thread.TaskQueue; - -import java.util.Queue; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * A much, much faster implementation of TaskQueue.Prioritized which avoids excessive overhead when checking for - * messages in the queue by avoiding usages of the Stream API. The improvement from this change can be most noticeably - * seen when enqueueing light updates which occur during block updates. - */ -public class ArrayPrioritizedTaskQueue implements TaskQueue { - // A simple array type is used to avoid needing to allocate an iterator to work on the queue - private final Queue[] queues; - - // Instead of iterating over every queue to determine if work is present, we simply store a counter - private final AtomicInteger size; - - @SuppressWarnings("unchecked") - public ArrayPrioritizedTaskQueue(int count) { - this.queues = new Queue[count]; - - for (int i = 0; i < count; i++) { - this.queues[i] = Queues.newConcurrentLinkedQueue(); - } - - this.size = new AtomicInteger(0); - } - - @Override - public Runnable poll() { - for (Queue queue : this.queues) { - Runnable task = queue.poll(); - - if (task != null) { - this.size.decrementAndGet(); - - return task; - } - } - - return null; - } - - @Override - public boolean add(TaskQueue.PrioritizedTask task) { - this.size.incrementAndGet(); - - Queue queue = this.queues[task.getPriority()]; - queue.add(task); - - return true; - } - - @Override - public boolean isEmpty() { - return this.size.get() <= 0; - } - - @Override - public int getSize() { - return this.size.get(); - } -} diff --git a/src/main/java/me/jellysquid/mods/lithium/mixin/world/chunk_task_system/ChunkTaskPrioritySystemMixin.java b/src/main/java/me/jellysquid/mods/lithium/mixin/world/chunk_task_system/ChunkTaskPrioritySystemMixin.java deleted file mode 100644 index 4ccbfa66c..000000000 --- a/src/main/java/me/jellysquid/mods/lithium/mixin/world/chunk_task_system/ChunkTaskPrioritySystemMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -package me.jellysquid.mods.lithium.mixin.world.chunk_task_system; - -import me.jellysquid.mods.lithium.common.util.thread.ArrayPrioritizedTaskQueue; -import net.minecraft.server.world.ChunkTaskPrioritySystem; -import net.minecraft.util.thread.MessageListener; -import net.minecraft.util.thread.TaskExecutor; -import net.minecraft.util.thread.TaskQueue; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; -import java.util.concurrent.Executor; - -/** - * This replaces the queue used by the chunk job executor to a much quicker variant. - */ -@Mixin(ChunkTaskPrioritySystem.class) -public class ChunkTaskPrioritySystemMixin { - @Mutable - @Shadow - @Final - private TaskExecutor controlActor; - - /** - * Re-initialize the task executor with our optimized task queue type. This is a safe operation that happens only - * once at world load. No tasks will be enqueued until after the constructor is ran, so we do not need to worry - * about copying them. - */ - @Inject(method = "(Ljava/util/List;Ljava/util/concurrent/Executor;I)V", at = @At("RETURN")) - private void init(List> listeners, Executor executor, int maxQueues, CallbackInfo ci) { - this.controlActor = new TaskExecutor<>(new ArrayPrioritizedTaskQueue(4), executor, "sorter"); - } -} diff --git a/src/main/resources/lithium.mixins.json b/src/main/resources/lithium.mixins.json index 52499ab6d..2e0486214 100644 --- a/src/main/resources/lithium.mixins.json +++ b/src/main/resources/lithium.mixins.json @@ -134,7 +134,6 @@ "world.chunk_access.ChunkHolderMixin", "world.chunk_access.ServerChunkManagerMixin", "world.chunk_access.WorldMixin", - "world.chunk_task_system.ChunkTaskPrioritySystemMixin", "world.chunk_tickets.SortedArraySetMixin", "world.explosions.ExplosionMixin", "world.inline_block_access.WorldChunkMixin",