Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Improvement: high-requency listener #4402

Merged

Conversation

RedstoneFuture
Copy link
Member

@RedstoneFuture RedstoneFuture commented Apr 16, 2024

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

Edit tasklist title
Beta Give feedback Tasklist Submitter Checklist, more options

Delete tasklist

Delete tasklist block?
Are you sure? All relationships in this tasklist will be removed.
  1. Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
    Options
  2. Ensure that the pull request title represents the desired changelog entry.
    Options
  3. New public fields and methods are annotated with @since TODO.
    Options
  4. I read and followed the contribution guidelines.
    Options

@RedstoneFuture RedstoneFuture requested a review from a team as a code owner April 16, 2024 22:38
@@ -164,114 +151,6 @@ public static void sendBlockChange(final org.bukkit.Location bloc, final BlockDa
}, TaskTime.ticks(3L));
}

@EventHandler
public void onRedstoneEvent(BlockRedstoneEvent event) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a separate class without making any changes.

}

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPhysicsEvent(BlockPhysicsEvent event) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a separate class without making any changes.

private static final Set<Material> PHYSICS_BLOCKS = Set.of(
Material.TURTLE_EGG,
Material.TURTLE_SPAWN_EGG
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These sets were only used in the methods involved and could/must also be moved.

@dordsor21 dordsor21 merged commit f88ea94 into IntellectualSites:main May 13, 2024
9 checks passed
@RedstoneFuture RedstoneFuture deleted the performance/redstone-listener branch May 13, 2024 19:25
pull bot pushed a commit to Craftstuebchen/PlotSquared that referenced this pull request May 16, 2024
* Adding new 'high-frequency-listener' setting

* Moving high-frequency event listener in new class

* Small typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants