#(apemademid) `calculate_xp` gets rather slow

9 messages · Page 1 of 1 (latest)

glad palm
#

I was playing with an inventory switcher script which stores the whole player's state per group of worlds. Simple thing so your event worlds get a different inventory than your survival worlds, which also store various information such as health, food level, enderchest, etc, and the player's XP.

Everything worked smoothly, storing the state of inventories, clearing and setting them within a single tick worked fine. Then I ran the script again a bit later, but this time it was slow. As in, I ran the script, the server froze for about a second, then went back to normal and switched my inventory. What was the source of this was my xp level.

Spark to the rescue, it's apparently com.denizenscript.denizen.scripts.commands.player.ExperienceCommand.XP_FOR_NEXT_LEVEL() which I assume to be called within <player.calculate_xp> causing the delay.

https://spark.lucko.me/0Wad0gd8kO

Simple enough command that seems to confirm: /ex experience set level 2147483647 (that number being the highest level i managed to set), followed by /ex narrate <player.calculate_xp>. And surely enough, the time between submitting the command and getting the XP back is by far longer than expected.

spark is a performance profiler for Minecraft clients, servers, and proxies.

fiery owlBOT
#

(apemademid) calculate_xp gets rather slow

fiery owlBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

summer gustBOT
#
Changed to Bug

Thread is now a Bug thread. This indicates a core code bug that a developer must resolved, not an error message or other support topic. Please do not misuse the Bug label. Use </helpthread:1028674284870180883> to switch the thread back to a normal help thread if you are not 100% confident it is a code bug.

glad palm
#

It doesn't matter to me, as it's an amount of XP that will never be reached in survival. I was just playing with XP randomly, and it just so happened to be right after I was working on the inventory thing. Will likely never be impacted by it.

But might be something to look into for someone else

past hamlet
#

well yeah

#

you set level to 2 billion and then loop 2 billion times, it'll be slow