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

Next steps for improving GC performance and configurability #6652

Open
dktapps opened this issue Mar 15, 2025 · 2 comments
Open

Next steps for improving GC performance and configurability #6652

dktapps opened this issue Mar 15, 2025 · 2 comments
Labels
Category: Core Related to internal functionality Performance Type: Enhancement Contributes features or other improvements to PocketMine-MP

Comments

@dktapps
Copy link
Member

dktapps commented Mar 15, 2025

Problem description

Since the implementation of #6554, several server owners have been discovering that GC is the source of many of their mysterious performance woes.

This PR didn't worsen performance, but it did make the problem appear in an obvious place in timings reports, rather than in random code pathways.

I was aware when I made the PR that the parameters were probably not optimal for PM's use case, but my focus was on ensuring that the behaviour properly mirrored the PHP standard behaviour so that I didn't accidentally hurt performance. It appears I succeeded in that goal, and now it's time to do something about these issues.

Proposed solution

Several steps come to mind:

  • Allow turning off the cycle GC entirely. PM by itself doesn't really need it (since it destroys all known cycles explicitly when objects are done with), and if plugin devs on servers are conscious of cycles, they may not need this expensive GC at all.
  • Allow configuring GC parameters like the GC threshold step, GC starting buffer size, GC threshold increase trigger, etc.
  • Allow setting a minimum time between GC runs. Larger servers have found that the GC runs far too frequently and wastes lots of CPU time trying to collect long-lived objects like Server and Player.
  • Look at integrating something like ext-gcignore so we can stop the GC wasting time on expensive objects. This will significantly reduce the GC burden.

Alternative solutions or workarounds

No response

@dktapps dktapps added Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP Performance labels Mar 15, 2025
@GameParrot
Copy link
Contributor

Would it be possible to make an extension that helps developers find the source of cycles

@dktapps
Copy link
Member Author

dktapps commented Mar 15, 2025

Unfortunately the GC doesn't give us much outward stats information, so it's difficult to see what types of objects it's spending time on. I only experimentally verified that Server, Player and World objects were wasting a lot of time. Getting more out of it would require modifications to php-src because that information isn't exposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core Related to internal functionality Performance Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

No branches or pull requests

2 participants