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 optimizations: Pathfinder ~70x faster, also improved general tick speed #1474

Open
wants to merge 1 commit into
base: master-1.21
Choose a base branch
from

Conversation

Lssikkes
Copy link

Before:
image

(tick 12-15 ms, destroying one block 7000 ms stall on server)

After:
image

(tick 4-5 ms, destroying one block 117 ms stall on server)

… speed with lots of devices (17 ms to 3 ms in test scene)
@CLAassistant
Copy link

CLAassistant commented Feb 16, 2025

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

Coverage Status

coverage: 39.004% (+0.004%) from 39.0%
when pulling 6e632c2 on Lssikkes:master-1.21
into cef2379 on CyclopsMC:master-1.21.

@rubensworks
Copy link
Member

Thanks for this @Lssikkes!

It has been on my todo-list for a long time to look into such large-scale performance analysis, but you beat me to it :-)
By the way, did you have an automated way of creating such large networks? If yes, could you share these? As this could be useful for avoiding future performance regressions.

I will have a more detailed look at this PR in the near future.

@Lssikkes
Copy link
Author

Unfortunately not automated, I just added worldedit and started creating a few large slabs with //set integrateddynamics:cable .. And then pointed VisualVM at it. With worldedit it still lags a lot because for every block placement it does, it will recalculate the whole network. Probably something to be done there that it defers network updates until post tick, and then check if the blocks have already been touched or so, to prevent it from going that wild. But it doesn't happen in normal gameplay too much (except when detonating a TNT/creeper inside the dense cable grid, that'll create similar performance issues), so I don't think it's of the highest priority.

Here's my save:
TestWorld.zip

Copy link
Member

@rubensworks rubensworks left a comment

Choose a reason for hiding this comment

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

I just have one possible suggestion. Everything else looks perfect to be merged!

@@ -107,7 +107,7 @@ public void onWorldTick() {
this.states.remove(oldPosition);
this.instances.remove(oldPosition);
}
this.oldPositions = Sets.newHashSet(newPositions);
this.oldPositions = (Set<PartPos>)newPositions;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of the cast, we can probably change the signature of the getPositions method.
Unless you see a specific reason for doing it like this? (not needed for backwards-compat, as no other mods are calling getPositions)

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.

4 participants