Skip to content

mob spawn cancellation back-off #5076

@electronicboy

Description

@electronicboy

[Not feeling well, but, wanted to make this issue while I remembered, please bear with me]

A common issue with mob spawning in modern versions of the server is how expensive and heavy-handed it is, plugins that clear mobs in the world often induce these types of spikes

In vanilla, the seeming reliance on mob spawning is that when you log in, you'll quickly (within a hanful of ticks to my recollection of the logic/experience) hit the spawn limit, it seems that the intent is that you'll stick to the mob limits pretty closely and deal with mobs slowly spawning back in due to the nature of things like the hard/soft despawn ranges removing mobs slow enough for the server to spawn the back in a small number each tick as they die off, this is fine;

However, there comes an issue due to this with when mobs spawns are canceled, e.g. such as with worldguard, in that the server will consistently try to meet the spawn targets, this is especially an issue with aspects like per player mob spawning, in which it's pretty easy for a plugin preventing spawns in a region for a handful of players to spend a good few ms trying to spawn mobs (I've personally seen this off the top of my head peek to 7-10ms with just bats prevented on some servers)

While, solving this on a global level is generally unviable, imho, there is no sane way to guarantee mob spawns without some form of granularity to ensure that spawning stays sane (the way the vanilla logic works has me worried that a global/chunk based attempt would introduce more caveats than worth investigating), it would potentially be ideal for per-player mob spawning to have a per-player back-off, easiest way I can see to do this is to artificially increase the number of mobs it sees for a player, if the server has had 3 mobs spawns, act as if we have 3 extra mobs in the chunk when checking the limits to allow us to back off here, and slowly bleed those off

This is just a theory as to what can be done to improve the performance of servers using things like protection plugins, there may be other solutions or the idea here may be so nuanced to implement, this does not solve a few vanilla issues with how spawning e.g. cases where there are few viable places for mobs to spawn can also induce similar performance penalties

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: performancestatus: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.status: input wantedLooking for community feedback on this issue.type: featureRequest for a new Feature.
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions