How does ticking of inactive villagers work?

Recently I encountered HUGE lag on my 1.15.1 Paper server, I ran spark profiler and figured out it is because of villagers path- and goal-finding.
While I found several villagers farms on my server, I also had tick-inactive-villagers enabled.
Now I wonder, how does it work? Does it mean that server ticks all villagers on server?
My players also use /rtp a lot, is it related to villagers ticking? I thought that players may encounter a lot of villagers via using rtp, does server actually have some mechanism to optimize that or something?

After I disabled tick-inactive-villagers I have ~20 TPS in the same situation when I previously had ~13-15.

Now I think that if it is indeed the case I can write some plugin to manually track and refresh villagers trades when player interacts with them.

Just looking for some help from someone who knows Spigot/Paper internals.

Paper, by extention of spigot, has an entity activation range feature, (referred to as EAR), the EAR means that entities in loaded chunks outside of the activation range will not be ticked as often, for most entities, this really ain’t an issue so long as certain steps are taken to ensure that their state remains consistent, villagers however are a total pain in the ass and needed to be consistently ticked in order to ensure that their logic is ran to maintain things like village linking and other villager oddities working properly; You can disable that setting and save a substantial amount of performance, you do however risk breaking villager farms

1 Like