[SPIGOT-3412] Command Functions are significantly more expensive than on a Vanilla server Created: 12/Jul/17 Updated: 13/Jul/17 Resolved: 12/Jul/17 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Major |
Reporter: | Misterx7772 | Assignee: | Unassigned |
Resolution: | Invalid | Votes: | 0 |
Labels: | 1.12, Command, functions | ||
Environment: |
CentOS release 6.9 |
Attachments: |
![]() |
Description |
Upon switching my mapmaking server from vanilla to spigot, I've noticed a significant increase in CPU usage. Commands in function seemingly work as expected, however it seems like Functions are overall inefficient. I've provided a few functions in the attached files which run random commands. Put the functions folder inside a blank world's data folder (this will kill all entities and make misc modifications to the world, so don't run it on an existing world), start the server with the vanilla server software. Teleport yourself to x=0 y=5 z=0 then run:
function lagtest:init Note the average CPU & spikes (a couple minutes should be enough to get an idea), then run the server with Spigot. In my case, on vanilla I had on average ~20% core usage, with spikes to ~40-50%, whilst using Spigot I had on average ~40% & spikes to >90-100%. In my map, lag essentially increased by a factor of 2 with spigot, but when a lot of functions runs at once the performance violently dwindles even more.
|
Comments |
Comment by md_5 [ 13/Jul/17 ] |
Functions are not run at level 3, they are run at the permission level of their caller. Player - /function Bukkit even allows for example assigning specific permission levels to specific command blocks. |
Comment by Misterx7772 [ 13/Jul/17 ] |
That would make sense. To clarify, I was looking into running Spigot in order to put a map project (game made solely using Minecraft's commands in order to be compatible without mods) onto a bungeecord proxy instead of having to connect via a separate address. The example using thousands of commands a second was intended, meant to have a constant drain on CPU to compare. Functions are essentially ran as OP level 3, so are permission checks needed at all? Now this might be more of a feature request, but I'd suggest maybe disabling them for stuff run inside Command Functions? Thanks for the answer though, always good to know what's the cause of performance loss. |
Comment by md_5 [ 12/Jul/17 ] |
We do much more with functions than on Vanilla. EDIT: Just looking at your example + using a profiler you are executing about 10,000 commands a second which is why you are seeing this behaviour. I can also confirm most of the difference in performance comes from checking permissions and command block overrides. |