Possible performance problem with UnmodifiableConfig
See original GitHub issueI was analysing my Minecraft setup with JFR to find mods that were misbehaving. One of the hottest methods from outside Vanilla came from LambDynamicLights. (In the JFR recording, I just stood still and looked around my base.)
The hot method is Arrays.copyOf(Object[], int) which is responsible for > 1% of all CPU cycles. The stack trace leading to this is:
java.util.Arrays.copyOf()
[JDK internal stuff]
java.util.ArrayList.add()
dev.lambdaurora.lambdynlights.shadow.nightconfig.core.utils.StringUtils.split()
dev.lambdaurora.lambdynlights.shadow.nightconfig.core.UnmodifiableConfig.getOrElse()
which is called from dev.lambdaurora.lambdynlights.DynamicLightsConfig.hasEntitiesLightSource() and dev.lambdaurora.lambdynlights.DynamicLightsConfig.hasBlockEntitiesLightSource(), respectively.
I have not dived into the the source code yet, but by the name of the class, it sounds like getting an “Unmodifiable Config” should not really have to do a string split (which ends up doing array copies) each time it is called. I imagine there is some easy room for improvement here.
Let me know if you want me to submit a PR with a fix. (I suspect a developer familiar with the code can make it quicker than I, but I’m willing to help if there is not enough resources on the project.)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)

Top Related StackOverflow Question
Very sorry but while reading I totally missed this part, feel free to PR, I’m not currently much available so any help is appreciated.
Fixed by commit 2678e56a2fc63531f2d9d9f59dfafdab7217f88e.