perf: cache display item names to eliminate per-search skull construction#92
Merged
Conversation
Problem: FilterType.BY_DISPLAY_ITEM_NAME called getDisplayRecipes() live on every Slimefun machine during each player search. getDisplayRecipes() clones SlimefunItemStacks, which triggers CraftMetaSkull.applyToItem and CraftPlayerProfile.<init> for every skull-based display item. CraftPlayerProfile construction fires HTTP requests to Mojang sessionserver, causing 429 rate-limit errors and TPS drops on the server thread. Spark profiler confirmed CraftPlayerProfile.<init> (91 nodes) and CraftMetaSkull (390 nodes) were all rooted in SearchGroup.filterItems via the BY_DISPLAY_ITEM_NAME filter. Fix: - SearchGroup: add DISPLAY_ITEM_NAMES_CACHE (Map<String,List<String>>), a hard-reference map from Slimefun item ID to lower-cased display names from getDisplayRecipes(). Populated once during init() alongside CACHE2. - FilterType.BY_DISPLAY_ITEM_NAME: replace live getDisplayRecipes() calls with a lookup against DISPLAY_ITEM_NAMES_CACHE. No ItemStack clone, no CraftMetaSkull, no CraftPlayerProfile, no Mojang HTTP request at search. - Removed unused imports from FilterType (AContainer, MultiBlockMachine, RecipeDisplayItem, SpecialMenuProvider, Debug). - pom.xml: bump Lombok 1.18.34 -> 1.18.38 for JDK 25 compatibility.
Fixes NoClassDefFoundError on Leaf 1.21.11 (modern Paper, no versioned CraftBukkit packages). 1.10.13-SNAPSHOT ships Wrapper26_R1 which uses the un-versioned org.bukkit.craftbukkit.* import path that Leaf uses.
balugaq
approved these changes
May 23, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
SearchGroup: addDISPLAY_ITEM_NAMES_CACHE(Map<String, List<String>>), populated once duringinit()alongsideCACHE2. Stores lower-cased display names fromgetDisplayRecipes()per item ID.FilterType.BY_DISPLAY_ITEM_NAME: replace livegetDisplayRecipes()calls with a lookup against the cache. EliminatesCraftMetaSkull/CraftPlayerProfileconstruction at search time, which was firing Mojang sessionserver HTTP requests and causing 429 rate-limit errors.Root cause
Every player search triggered
BY_DISPLAY_ITEM_NAME, which calledgetDisplayRecipes()live per item. For skull-based display items this clones aSlimefunItemStack, constructsCraftMetaSkullandCraftPlayerProfile, and fires an HTTP request tosessionserver.mojang.com. Under load this saturates Mojang's rate limit (HTTP 429) and stalls the server thread.Spark profiler confirmed
CraftPlayerProfile.<init>(91 call-tree nodes) andCraftMetaSkull(390 nodes) were all rooted inSearchGroup.filterItemsvia this filter.After
Display name lookup is a plain
Map.get+ stringcontains-- no object allocation, no HTTP, no Mojang round-trip.Live-tested on production server
Deployed on a Leaf 1.21.11 server with ~133 plugins (heavy Slimefun ecosystem including SlimeAE, NetworksExpansion, LogiTech, InfinityExpansion). All addon integrations verified working after the fix.