The problem with long hooks

Dear nivex, could you please tell me why, after the latest update, I started receiving messages of this kind, and the server began to lag significantly? Perhaps it’s my fault, as several other plugins are doing the same thing, but TruePVE is the leader in terms of messages of this kind.

Calling 'OnNpcTarget' on 'TruePVE v2.4.6' took 224ms [GARBAGE COLLECT]
Calling 'OnNpcTarget' on 'TruePVE v2.4.6' took 102ms
Calling 'OnNpcTarget' on 'TruePVE v2.4.6' took 126ms

heya, remove the AnimalsIgnoreSleepers flag from your config.

It's because the BaseNPC2 class for newer animals calls the OnNpcTarget hook too frequently. The flag shouldn't be used because of this, and will likely be removed.

Animals ignore sleepers until server startup is complete already, and the tpve.sleepers command can be toggled to protect them temporarily without requiring that flag. The flag should be removed.

nivex

heya, remove the AnimalsIgnoreSleepers flag from your config.

It's because the BaseNPC2 class for newer animals calls the OnNpcTarget hook too frequently. The flag shouldn't be used because of this, and will likely be removed.

Animals ignore sleepers until server startup is complete already, and the tpve.sleepers command can be toggled to protect them temporarily without requiring that flag. The flag should be removed.


 
Thank you very much, nivex.


Merged post

Wow !This is something new.

[CSharp] Started Oxide.Compiler v successfully
TruePVE was compiled successfully in 2715ms
Unloaded plugin TruePVE v2.4.6 by nivex
Loaded plugin TruePVE v2.4.6 by nivex
Calling 'CanLivestockAnimalRefuseTarget' on 'TruePVE v2.4.6' took 127ms
Calling 'CanLivestockAnimalRefuseTarget' on 'TruePVE v2.4.6' took 102ms
Calling 'CanLivestockAnimalRefuseTarget' on 'TruePVE v2.4.6' took 309ms [GARBAGE COLLECT]



Merged post

Can TruePVE not subscribe to this hook for livestock animals, or at least quickly return null for them? Or is that not the problem?

hi, that's not the problem. it is the same issue as the OnNpcTarget hook, except that I cache results for this and it returns quickly already so it is not the plugin. consistent issues like this show that something is wrong with the server. time warnings when a plugin loads is to be expected though, that is not unusual.