Skip to content

Big cleanup#11

Merged
kaboombot merged 14 commits intokaboomserver:masterfrom
amyavi:cleanups
Mar 8, 2025
Merged

Big cleanup#11
kaboombot merged 14 commits intokaboomserver:masterfrom
amyavi:cleanups

Conversation

@amyavi
Copy link
Copy Markdown
Contributor

@amyavi amyavi commented Jun 23, 2024

See commit names and descriptions for more info

Before:
image

After:
image

This would obviously scale with more spambots, and the lag would be way, way worse on actual Kaboom, as the hardware is much weaker than my computer.

amyavi added 12 commits June 23, 2024 12:41
This hides commands from players that are being controlled with
iControlU.
Since we don't use NMS, this is harmless. Saves about 100ms of startup
time on first boot on my machine
Finalizes everything, adds @NotNull to onCommand parameters, and uses
pattern matching for the onCommand instanceof Player check.
This was done so spamming CommandSpy commands wouldn't lag the server as
much, and having a bunch of players turn on CommandSpy wouldn't fill up
the server storage.
We should probably keep kaboom plugins' API version synced with the main
server
@amyavi
Copy link
Copy Markdown
Contributor Author

amyavi commented Aug 6, 2024

I hate to nag people, but this PR has been sitting here for a while. Bump.

@amyavi
Copy link
Copy Markdown
Contributor Author

amyavi commented Oct 1, 2024

@kaboombot Bump

1 similar comment
@OptimisticDeving
Copy link
Copy Markdown

@kaboombot Bump

@OptimisticDeving
Copy link
Copy Markdown

@kaboombot Bump

Comment on lines +3 to +4
import com.google.common.io.Files;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What provides these dependencies?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Minecraft (the vanilla server) utilizes them.

@Override
public void onEnable() {
config = getConfig();
this.config = new CommandSpyState(new File(this.getDataFolder(), "state.bin"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need an unreadable binary file?

Copy link
Copy Markdown
Contributor Author

@amyavi amyavi Jan 24, 2025

Choose a reason for hiding this comment

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

The old YAML config would quickly grow in size to several megabytes after a few hours of the server being online, as bots log in with random usernames and turn on CommandSpy. This is the most efficient way to do it, utilizing only 16 bytes per player, instead of 43 like before.

@kaboombot
Copy link
Copy Markdown
Member

It's a lot of additional code, so I'd appreciate if you could break down how each part improves performance.

@amyavi
Copy link
Copy Markdown
Contributor Author

amyavi commented Jan 24, 2025

It's a lot of additional code, so I'd appreciate if you could break down how each part improves performance.

Firstly, the entire state saving system was rewritten to use a custom binary format instead of YAML. This means that when saving the config, we do not need to go through an entire YAML serializer, but instead just write the UUID bytes to disk.

This is already a lot faster than the old system, but to further improve the performance, I also made it so the full state is only saved every 30 seconds or on server shutdown, instead of every time /commandspy was executed like before.
The config also does not get re-saved if no players changed their state since the last save.

The PR also adds a small feature that allows players to toggle other people's CommandSpy, much like the Essentials /vanish command. This should allow bots to manage their cspy state completely inside of command blocks, reducing chat spam. Example: /c amyavi on

Normally these sorts of performance changes wouldn't be required, however as Kaboom is filled with bots that utilize commandspy to log commands, it's common to see the server lag small amounts due to a large amount (6-8) of bots trying to enable commandspy at the same time, e.g. at the server start.

@amyavi amyavi mentioned this pull request Feb 3, 2025
@kaboombot kaboombot merged commit fac2dfe into kaboomserver:master Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants