Skip to content

Performance

Matej edited this page Jan 17, 2025 · 7 revisions

ChatControl is an extremely optimized plugin, if you understand how it works and configure it with respect to your hardware and player base.

What Affects Performance

The magic lays in the word "if". For example: For every chat message, we have to do the following:

  • Compile each format part
  • Add gradients if used
  • Launch JavaScript if format conditions are used
  • Replace variables, including JavaScript ones
  • Check each word for all rules
  • Log the message
  • Send it to spies (where some of the above re-applies again)

All of this is up to you and can be completely disabled.

That's just an illustration for what happens with each chat message. Below you'll find the other parts of the plugin that are heavily affected based on your configuration:

  • Rules (rules/ folder) — their amount, conditions AND each regex
  • Formats (formats/ folder) - each format option such as JavaScript conditions
  • Messages (messages/ folder) - their amount and conditions
  • Variables (variables/ folder) - their amount and conditions

ALL of this is up to you and can be completely disabled. Saying that ChatControl has poor performance while having a huge inefficient regular expressions, hundreds of format parts with javascript conditions running on a mediocre hardware is false.

The plugin's performance is 80% dependent on you, so please review the above sections and configure carefully.

Optimizing Performance

Here's quick tips to toggle in your settings.yml to improve ChatControl's performance:

  • See the Performance section and disable all keys there for maximum performance.
  • Rules.Case_Insensitive set to false: Disables the "match" operator evaluating messages case insensitively.
  • Private_Messages.Toasts set to false: Disable write/read disk operations from showing Advancements (as popups). Notable performance boost.

ProtocolLib

If ProtocolLib.Enabled is on true in settings.yml, each message needs to be decoded and saved. This is NOT done nor can be improved by us since we rely on ProtocolLib APIs which further call NMS and Adventure.

This is to support the [X] message removal feature. On servers with heavy chat load or crap hardware this will show on timings. You can disable this feature.

Rules

The larger your regular expression, the more cycles your computer need to evaluate it. You can use regex101.com website to test how many cycles and time approximately each expression takes.

When testing a rule on regex101.com make sure you toggle "insensitive" and "unicode" flags when testing expressions to get accurate (including performance) results: https://i.imgur.com/QEDZx5N.png

Spark Profiler

If you're still experiencing performance degradation, please install the spark profiler and open a new issue ticket with a full report from a running production server (ensure to keep profiling for a significant enough time such as 30 minutes or even 2 hours on smaller servers).

Clone this wiki locally