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

Improve performance of chunk loaded metric and offline player count #226

Merged

Conversation

radiant-ai
Copy link
Contributor

Noticed spike of mspt on regular interval and upon inspection noticed that the main contributor are three metrics of the plugin:

image

For players total metric. Solution:

  • make the collection async, it looks like server only reads players from .dat files to do it, which is safe to run off the main thread

For loaded chunks count. It looks like the getLoadedChunks() method makes a copy of all the chunks, which is extremely slow when there are many chunks loaded. Solution:

  • do the call only once when the metric is first requested, calculate all subsequent metrics by manually tracking number of loaded chunks per word.

Regarding entities, it is also possible to do same approach as with chunks, but this will be a bit more effort.

@sladkoff
Copy link
Owner

Hi @radiant-ai can you please rebase? The CI build has been fixed on master.

@radiant-ai radiant-ai force-pushed the fix_lag_on_player_and_chunk_total branch from 7ea4f61 to e7de226 Compare February 28, 2024 14:25
@sladkoff
Copy link
Owner

@radiant-ai Thank you 🙏

@sladkoff sladkoff merged commit f04c2f1 into sladkoff:master Feb 28, 2024
1 check passed
@sladkoff sladkoff added this to the 3.0.0 milestone Feb 29, 2024
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

2 participants