ChatControl-Red icon indicating copy to clipboard operation
ChatControl-Red copied to clipboard

1.21.4: Lag issue with simple rule?

Open bobhenl opened this issue 9 months ago • 1 comments

Are you using MySQL?

No

Are you using a proxy?

No

"/version ChatControlRed" - plugin version

11.2.8

Optional: Error log

No response

ZIP of "/chc debug"

No response

Steps to reproduce

Hello, recently there was strange lag issue when the rule got triggered?

[13:09:12] [Server thread/INFO]: AuzstiantGacaut issued server command: /shop
[13:09:12] [Server thread/INFO]: [ChatControl] *--------- Rule match (command) for AuzstiantGacaut --------- 
[13:09:12] [Server thread/INFO]: [ChatControl] MATCH: ^/shop
[13:09:12] [Server thread/INFO]: [ChatControl] CATCH: /shop
[13:09:12] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 3475ms or 69 ticks behind

Byy the spark report this rule consumed over 1s:

Image

Image https://spark.lucko.me/zgM9g1a9ZA

but the rule is this simple?

match ^/shop
ignore perm group.newbie
require variable {votingplugin_canvote} true
then warn &c&lShop &8» &fTo get HUGE double or triple better buy & sell prices, vote on remaining sites in &b[&e/vote&b]&f!

Any reason behind this?

But the rule was executed 2 mins after as well and there it consumed probably much less as you can see by spark? So maybe it was caused by something else as well?

bobhenl avatar Mar 23 '25 14:03 bobhenl

But it seems to happen regularly

Image

Image https://spark.lucko.me/ocSVNJlpdH

Is there something on that rule that could cause the issues?

I guess it's maybe just associated with the command listener?

Image

Image

And here something strange with onQuit?

Image https://spark.lucko.me/yoyVG5kWBx

Image

bobhenl avatar Mar 23 '25 19:03 bobhenl

Apologizes for the delay as I was out of office; I'll be reviewing this in 24 hours or less.

kangarko avatar Mar 27 '25 19:03 kangarko

Hello,

Sorry again for delay, I fell ill after coming home. I pushed a commit which calls a more performant method to strip rules of colors and got rid of the compile calls in each loop argument if you used "replace before".

Otherwise if it continues to happen, I recommend setting Rules.Strip_Colors to false in settings.yml and using "strip colors" operator for only those rules that need stripping (i.e. curse words)

kangarko avatar Mar 31 '25 17:03 kangarko

Seems like it is still lagging a bit, even when I listed only the rules of swearings. Maybe I have so many of them that it could cause the issue? If I comment that & don't use the strip colors anywhere, then chatcontrol is really lightweight.

Also, is it same if I: -> turn Rules.Strip_Colors to false & set true only to swearings -> Rules.Strip_Colors to true & set false only to commands should it have the same effect?

But back to my initial question. Currently I have around 1234 swear blocks (only the basic variants like this:

match \b(arse)\b

and I have it x2 because I use slight different group for chat & for other types. Do you think it could have the effect on the Strip_Colors rule? Like if it needs to be applied to 1234*2 matches? But still, they aren't "checked" at once, or are they?

And just from the performance point of view, do you think it will be better to make better regex that will include various word variants & bypasses, or split them into different matches like this?

match \b(fuckersucker)\b
# strip colors true
group swearchat
ignore command /ban|/tempban|/mute|/tempmute|/banip|/kick|/warn|/jail|/history|/dupeip|/alts|/history
match \b(fuckface)\b
# strip colors true
group swearchat
ignore command /ban|/tempban|/mute|/tempmute|/banip|/kick|/warn|/jail|/history|/dupeip|/alts|/history
match \b(fuckfest)\b
# strip colors true
group swearchat
ignore command /ban|/tempban|/mute|/tempmute|/banip|/kick|/warn|/jail|/history|/dupeip|/alts|/history

like if it would be better blocking whole "fuck*" instead of blocking it like this? For performance?

Also one more question: Do you recommend us replacing all legacy colors across settings + messages & other files with etc. or isn't it needed? Does it have some impact on performance?

bobhenl avatar Apr 01 '25 21:04 bobhenl

Unfortunately yes, see my source code, I need to apply the color strip 1234*2 times in that case. Because we never know if the rule changes the message we need to re-apply the strip for the most up-to-date message since rules are read from top to bottom. I could add some complicated logic to cache message for rules not editing it when I have more time. Contributions are also welcome :)

Yep, better regex will def help. You can ask GPT 4.5 for that and regex101.com to measure the perf improvements.

Actually & legacy parsing is way faster, keep it.

In your case I recommend turning Rules.Strip_Colors off and not using strip colors at all. Can your players use colors in chat? If not then you dont need to use it at all. If only VIP/sponsors can use colors I would assume they wont risk a ban bypassing the filter since they paid.

kangarko avatar Apr 03 '25 15:04 kangarko

Yeah, that's true. Thanks so much then for the answer. I'll look into Chatgpt to measure performance & make some better regex. I initially thought that applying a bit more complex REGEX would be worse for performance than checking from top to bottom, but this was the wrong thought.

And yes, I'll disable stripping rules, as I use it only for donators, and you're right about this.

Once more, thanks for responses.

bobhenl avatar Apr 03 '25 16:04 bobhenl

You're welcome! If I had more time I would love to see your full rules file and maybe I can do some caching in code, but unfortunately these months are very busy so best I could do was to open source the entire project.

Having said that, those changes I suggested should make the plugin way faster! :)

kangarko avatar Apr 03 '25 16:04 kangarko