From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 8 Apr 2020 21:24:05 -0400
Subject: [PATCH] Increase Light Queue Size

Wiz mentioned that large WorldEdit operations cause light to run on
main thread. The queue was small, set to 5.. this bumps it to 20
but makes it configurable per-world.

The main risk of increasing this higher is during shutdown, some
queued light updates may be lost because mojang did not flush the
light engine on shutdown...

The queue size only puts a cap on max loss, doesn't solve that problem.

diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 1b49c214998a5a9b424472df040d634d9fcc0c4a..d7e22e1bf886800adbe8ed7baa3349e5d2ee1818 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -609,4 +609,9 @@ public class PaperWorldConfig {
     private void zombieVillagerInfectionChance() {
         zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
     }
+
+    public int lightQueueSize = 20;
+    private void lightQueueSize() {
+        lightQueueSize = getInt("light-queue-size", lightQueueSize);
+    }
 }
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e57bda6223966171f15e0c6c24680a54c0edd83d..8e2300e22ca76562acf29c42c0025b4d4c2689b1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -660,7 +660,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
         this.executeModerately();
         // CraftBukkit end
         worldloadlistener.b();
-        chunkproviderserver.getLightEngine().a(5);
+        chunkproviderserver.getLightEngine().a(worldserver.paperConfig.lightQueueSize); // Paper - increase light queue size
         // CraftBukkit start
         // this.bc();
         worldserver.setSpawnFlags(this.getSpawnMonsters(), this.getSpawnAnimals());
