Calling 'OnEntitySpawned' on 'StackSizeController v4.1.1' took average 1611msSolved

My console keeps saying this: Calling 'OnEntitySpawned' on 'StackSizeController v4.1.1' took average 1611ms, Calling 'OnMaxStackable' on 'StackSizeController v4.1.1' took average 1278ms. And it wasn't doing it before this since the 2 months I've had the plugin. Help with a fix please?

Same Here. Have you found a fix?

This is a warning related to a hooks performance, it is usually harmless but can cause lag, but this can also be the result of server lag. I have not seen this warning personally, so could be server performance, or simply too many plugins interacting.

It was not too many Plugins. I purchased the Paid version and it works fine. 

There is not and never has been a paid version of this plugin, unless someone just stole my code, modified it a bit and resold it, which is probably what happened. 

We're also getting super-long times like the original poster.  It was fine before thursday's facepunch update and now it's not.  Whatever facepunch did, it seems to have affected this plugin as well as the recovery-on-death one (huge call times).  A fix would be greatly appreciated.  Edit:  We are suffering weird lag and it seems that the few plugins that are recording these long times are all that's left to diagnose.

Merged post

Stacksize Controller in my console, 699 seconds.  That's 11+ MINUTES.  It's ground zero for our lag spike.  This really, really needs to be updated.

The "took average *ms" hook warning can unfortunately be misleading about which hook actually caused it. The way the this tracking works in Oxide is that it tracks the cumulative hook time used by the plugin (for all hooks) every 10 seconds, and if that exceeds a certain amount, Oxide logs a warning during any hook call for that plugin, effectively blaming the hook that was called last even though it may have been other hooks that caused it.

The OnEntitySpawned hook implementation in this plugin isn't expensive, and it's really unlikely that the hook is being called enough to cause this issue. If entities were being spawned enough to cause significant hook time in this plugin, the majority of server lag would be caused by the spawning of entities themselves, since that is many times more expensive than the function that the plugin runs in response.

This is not related, but I strongly advise @AnExiledDev to merge https://github.com/AnExiledDev/StackSizeController/pull/20 which removes the OnEntitySpawned hook because it's no longer necessary as of an update that Facepunch made last year. This will reduce some load caused by the plugin.

The excess hook time is probably coming almost entirely from the OnMaxStackable hook, which is most likely occurring due to thousands of item moves per second because of bugged industrial systems. Many servers have seen this problem in the past few months, and it shows up commonly in plugins that use item-related hooks (CanAcceptItem, CanStackItem, OnItemSplit, OnMaxStackable). The problem is that the hooks are being called so many times that there is little that can be done in the plugins to optimize the problem away. Servers are effectively being DoSed by the industrial systems. Some servers have used debug plugins to identify the location of the problematic industrial systems so that an admin or moderator could manually disable them.

There are some micro-optimizations that can be made in this plugin to slightly reduce the hook time used. While small, these will add up at the scale of thousands of calls per second. First, I see multiple places in the GetStackSize function that use ContainsKey to check for existence of a key in a dictionary, then use the indexer to access the value of that key. Those can be replaced with a TryGetValue call which fulfills both the check and access with a single lookup. Second, the try/catch is not free and is not necessary, can be removed. Third, the OnMaxStackable hook can probably be removed entirely, since modifying item.info.stackable when the plugin loads should be sufficient, since the plugin doesn't care about the context of when/where the item is being stacked. Eliminating OnMaxStackable and OnEntitySpawned would basically eliminate all hook time used by the plugin.

Sorry I mistook this one for a paid version. My problem was so bad that I had to delete the plugin. I would also like to say that I wish Umod would let us pay for plugins here. This would give us a faster response time from all of you that have worked tirelessly to give us these plugins. 

As we all know, nothing is free. Someone had to spend there valuable time to create them and maintain them. 

Hey,
can confirm that it causes heavy lags with this: (all within 1 min ) and keeps sadly going on.

01:39 [Warning] Calling 'OnMaxStackable' on 'StackSizeController v4.1.1' took average 2765ms
01:39 [Warning] Calling 'OnMaxStackable' on 'StackSizeController v4.1.1' took average 1240ms
01:39 [Warning] Calling 'OnEntitySpawned' on 'StackSizeController v4.1.1' took average 2302ms
01:39 [Warning] Calling 'OnMaxStackable' on 'StackSizeController v4.1.1' took average 1165ms
01:39 [Warning] Calling 'OnMaxStackable' on 'StackSizeController v4.1.1' took average 2251ms
01:39 [Warning] Calling 'OnMaxStackable' on 'StackSizeController v4.1.1' took 105ms [GARBAGE COLLECT]
01:39 [Warning] Calling 'OnMaxStackable' on 'StackSizeController v4.1.1' took average 2565ms

the same spam happens when i use the stacks from mevent too, so i think its not caused by this plugin.

Yeah, we've got three plugins that are just running some staggering call times -- thankfully down to only three, and the severe server fps plunge continues, so it's pretty well narrowed down to those three with the 600+ second call times.

clintonla

Sorry I mistook this one for a paid version. My problem was so bad that I had to delete the plugin. I would also like to say that I wish Umod would let us pay for plugins here. This would give us a faster response time from all of you that have worked tirelessly to give us these plugins. 

As we all know, nothing is free. Someone had to spend there valuable time to create them and maintain them. 

Marketplace will be here I'm sure no later than 2035. 

NKXTQs24ExGTuL8.jpg WhiteThunder

The "took average *ms" hook warning can unfortunately be misleading about which hook actually caused it. The way the this tracking works in Oxide is that it tracks the cumulative hook time used by the plugin (for all hooks) every 10 seconds, and if that exceeds a certain amount, Oxide logs a warning during any hook call for that plugin, effectively blaming the hook that was called last even though it may have been other hooks that caused it.

The OnEntitySpawned hook implementation in this plugin isn't expensive, and it's really unlikely that the hook is being called enough to cause this issue. If entities were being spawned enough to cause significant hook time in this plugin, the majority of server lag would be caused by the spawning of entities themselves, since that is many times more expensive than the function that the plugin runs in response.

This is not related, but I strongly advise @AnExiledDev to merge https://github.com/AnExiledDev/StackSizeController/pull/20 which removes the OnEntitySpawned hook because it's no longer necessary as of an update that Facepunch made last year. This will reduce some load caused by the plugin.

The excess hook time is probably coming almost entirely from the OnMaxStackable hook, which is most likely occurring due to thousands of item moves per second because of bugged industrial systems. Many servers have seen this problem in the past few months, and it shows up commonly in plugins that use item-related hooks (CanAcceptItem, CanStackItem, OnItemSplit, OnMaxStackable). The problem is that the hooks are being called so many times that there is little that can be done in the plugins to optimize the problem away. Servers are effectively being DoSed by the industrial systems. Some servers have used debug plugins to identify the location of the problematic industrial systems so that an admin or moderator could manually disable them.

There are some micro-optimizations that can be made in this plugin to slightly reduce the hook time used. While small, these will add up at the scale of thousands of calls per second. First, I see multiple places in the GetStackSize function that use ContainsKey to check for existence of a key in a dictionary, then use the indexer to access the value of that key. Those can be replaced with a TryGetValue call which fulfills both the check and access with a single lookup. Second, the try/catch is not free and is not necessary, can be removed. Third, the OnMaxStackable hook can probably be removed entirely, since modifying item.info.stackable when the plugin loads should be sufficient, since the plugin doesn't care about the context of when/where the item is being stacked. Eliminating OnMaxStackable and OnEntitySpawned would basically eliminate all hook time used by the plugin.

Thanks, I probably can't take a look this weekend, but I'll look into that more, see what the hell Rust did to their game this time.

Yeah I get that, but my Console was sooooooo flooded with on entity spawn etc that I had to enter the Text into Console Filter just to block it out. Then I started noticing LAG because of the background spamming it was doing in the Console every 5-10 secs. So yeah no thx lol. Had to grab a completely different Plugin called Stack Modifier and the Issue was fixed immediately so yeah not sure what was going on lol. And the plugin Stack Size Controller didn't do that at first or at all. It started with Rust's last Update, not the Weapon Rack one.

jYG64m2P5VgcQ48.jpg raiven007

Yeah I get that, but my Console was sooooooo flooded with on entity spawn etc that I had to enter the Text into Console Filter just to block it out. Then I started noticing LAG because of the background spamming it was doing in the Console every 5-10 secs. So yeah no thx lol. Had to grab a completely different Plugin called Stack Modifier and the Issue was fixed immediately so yeah not sure what was going on lol. And the plugin Stack Size Controller didn't do that at first or at all. It started with Rust's last Update, not the Weapon Rack one.

Rust breaks plugins. Nothing new.

Yep agreed lol and they don't fix them lol but they should

I tested in last days some more plugins. With all of them i get console spam/heavy lag.
CustomSkinsStacksFix, Stacks by Mevent, Chest Stack Multiplier by Monah.. so the issue must be somewhere else.
Will try next to disable the raidable bases /stacksize option for loot. Otherwise no clue. :/

Locked automatically