There is a very noticeable performance degradation when accessing the MoLang scripting component in client scripts, which results in large frame drops.
I am attaching an example behaviour pack, and steps to reproduce this error (which do involve editing the client script, to present the impact this issue has and the small changes to cause this).
Some comparisons of frame rates before and after accessing this component:
50 fps to 8 fps. On updating said component, 6 fps.
40 fps to 5 fps. On updating, 3 fps. (Thanks to mrflippy#4110 in the Scripting Discord)
60 fps to 37 fps. On updating, 6 fps. (Thanks to Cold Fusion#0890 in the Scripting Discord)
Steps to reproduce:
Install the behaviour pack attached into the development behaviour pack folder.
Create a new creative mode flat world with no other entities (normal difficulty, no mob spawning, no mob loot, experimental gameplay, behaviour pack)
Load up the world.
Place down any block. (Notice that there is a line of creepers on top of the block.)
Note the initial fps.
Leave the world.
Edit the client script in the behaviour, and uncomment the lines indicated in the script itself for the second run (i.e. remove the
//
before it)Load the world.
Run
/kill @e[type=creeper]
Place down any block.
Note down the FPS.
Repeat steps 6-11 for the third run.
The first run was a baseline for the next runs. In the second run, simply adding a line to get the MoLang component off the ten creepers in the world caused a large frame drop, and then proceeding to update the component caused another in the third run.
As a side note, this error is currently only present on the Windows version of the game. Upon running the Android version (which is not available by default, but is accessible by other means) this entire performance impact is gone, and increasing the amount of creepers to double or even triple still causes no problems.
Attachments
Comments 5
Yes. Upon running my attached reproduction case in 1.12.0.9, I still get a frame drop from 60 -> 8 on getting the Molang component, with a further drop to 4 upon updating said component. (On updating/querying exactly 10 creepers in the world)
Cleaning up old tickets: This ticket has not been updated recently (~1 year+) so is being closed as Cannot Reproduce. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki
Here are some benchmarks of how much time does
getComponent
andapplyComponentChanges
take for the molang component provided by abc55#7088 on the Scripting Discord Server.getComponent min: 20, max: 33, avg: 23.33, median: 23
setComponent0 min: 3, max: 7, avg: 4.171, median: 4
setComponent1 min: 3, max: 6, avg: 4.434, median: 4
setComponent10 min: 5, max: 11, avg: 7.25, median: 7
setComponent50 min: 17, max: 27, avg: 19.548, median: 20
setComponent100 min: 30, max: 50, avg: 34.986, median: 35
Where,
getComponent
issystem.getComponent(entity, "minecraft:molang")
setComponentN
issystem.applyComponentChanges(entity, molangComponent)
wheremolangComponent
hasN
variables