PlotSquared icon indicating copy to clipboard operation
PlotSquared copied to clipboard

Performance Improvement: high-requency listener

Open RedstoneFuture opened this issue 1 year ago • 0 comments

Overview

As we know, the BlockPhysicsEvent is called very often, while not everyone needs the associated settings or flags.

With this PR I would like to outsource two high-frequency event-listeners to a separate class that can be explicitly deactivated in the settings.yml.

Description

  1. Adding high-frequency-listener setting (same setting names as the setting in WorldGuard):
# The activity of high-frequency event listener can be deactivated here to improve the server performance. 
# Affected settings: 'redstone' settings here below. Affected flags: 'disable-physics', 'redstone'. 
# Only deactivate this setting if you do not need any of the mentioned settings or flags.
high-frequency-listener: true
  1. Moving onRedstoneEvent(BlockRedstoneEvent event) and onPhysicsEvent(BlockPhysicsEvent event) from BlockEventListener.java to HighFreqBlockEventListener.java.

Performance Comparison

high-frequency-listener=true

= default value; behavior as before

grafik grafik

high-frequency-listener=false

= after deactivation of the high-frequency flags

grafik grafik

Test circuit

http://redstoneworld.de/downloads/intern/plugins/laggy_adder.zip

Note: It should be noted that the "/tps" command from Spigot still needs some time after the server start for the value to level out, as it is rounded here.


### Submitter Checklist
- [X] Make sure you are opening from a topic branch (**/feature/fix/docs/ branch** (right side)) and not your main branch.
- [X] Ensure that the pull request title represents the desired changelog entry.
- [X] New public fields and methods are annotated with `@since TODO`.
- [X] I read and followed the [contribution guidelines](https://github.com/IntellectualSites/.github/blob/main/CONTRIBUTING.md).

RedstoneFuture avatar Apr 16 '24 22:04 RedstoneFuture