FastEvent
speeding up the Event system in Forge/NeoForge

Что это
speeding up the Event system in Forge/NeoForge
- Тип: мод
- Загрузчик: forge, neoforge
- Версии Minecraft: 1.16.5 – 1.21.1
- Скачиваний на Modrinth: 1 434 920
Подробно
Long story short, the optimization approach still applies, but Forge/NeoForge does not allow mod to modify EventBus.
Unlike classes from Minecraft or Forge itself, EventBus is loaded not as part of the game, but as "library", which makes it impossible to modify EventBus via Mixin or Transformer.
In 1.2.0, in an effort of further improving performance, I used some dirty hack (or "non-standard approach" if you prefer) to modify the ASMEventHandler class, which is unfortunately broken in 1.18.2+. These releases are archived now, and are likely not receiving further update.
is a Forge/Neoforge optimization mod that optimizes one of the most fundamental systems in Forge: the Event system.
It's not easy to make a test case for every supported Minecraft version, especially when the Event system for these versions are different from each other. So instead, I will provide a JMH benchmark report from a PR I made for Cleanroom project, in which I used the same optimization approach as FastEvent:
Register 10,000 event listeners, post event 0 times:
Benchmark Mode Cnt Score Error Units BusPerformanceTest.register10000Legacy avgt 5 1126.498 ± 284.633 ms/op BusPerformanceTest.register10000Modern avgt 5 1058.961 ± 173.586 ms/op
Register 1,000 event listeners, post event 10,000 times:
Benchmark Mode Cnt Score Error Units BusPerformanceTest.register1000test10000Legacy avgt 5 4407.963 ± 4250.643 ms/op BusPerformanceTest.register1000test10000Modern avgt 5 3550.578 ± 1991.352 ms/op
https://github.com/CleanroomMC/Cleanroom/pull/328#issuecomment-2801099504
When devs are using @EventBusSubscriber and/or @SubscribeEvent to subscribe event handlers, the EventBus cannot get the event handler magically, instead only a Method object is available. So the most straight-forward approach is use this object directly: method.invoke(...). This invocation will eventually be redirected by JVM back to the original method, allowing an event handler to receive an event after subscribing to it.
But this (method.invoke(...)) is really slow. To make it faster, the EventBus will, at runtime, generate event handler classes for every method it found, eliminating expensive reflection based invocation.
But generating classes introduces another slow-down. To make it even faster, FastEvent replaced class generation with lambda constructi
Как установить
Скачайте файл на официальной странице ниже и положите его в папку mods (для модов) или plugins (для плагинов) вашего сервера или клиента. Для модов нужен совместимый загрузчик. Версия должна совпадать с версией Minecraft.
Текст подготовлен автоматически из описания на Modrinth и ждёт проверки редакцией.
Комментарии 0
Комментарии к этому материалу отключены.
Читайте также
Better Archeology (1.20 Update)
Better Archeology adds new life to the archeology mechanic in Minecraft. 05.12.2026
Dragon Ball Z Totems Pack Optifine
A fan-made resource pack that transforms your Totem of Undying into Dragon Ball Z characters with OptiFine CIT support. Featuring Goku… 05.12.2026
Vivecraft Perfected - spooky scary edition
A variation of Vivecraft perfected leaning towards a horror experience 05.12.2026
Create: Eternal Zinc
This is an addon for the Create mod that makes zinc an infinite resource. 05.12.2026
TalkingClouds
Speech bubbles for players and for any other entities. 05.12.2026
New Sniffer Egg
Changing the texture of the sniffer egg to a more beautiful one! 05.12.2026