Dylan T. 8f8fe948c1
MemoryManager: Control when cycle garbage collection is run (#6554)
This PR replicates the mechanism by which PHP's own GC is triggered: using a dynamically adjusted threshold based on the number of roots and the number of destroyed cycles. This approach was chosen to minimize behavioural changes.

This currently only applies to the main thread. Doing this for other threads is a bit more complicated (and in the case of RakLib, possibly not necessary anyway).

By doing this, we can get more accurate performance profiling. Instead of GC happening in random pathways and throwing off GC numbers, we trigger it in a predictable place, where timings can record it.

This change may also produce minor performance improvements in code touching lots of objects (such as `CraftingDataPacket` encoding`), which previously might've triggered multiple GC runs within a single tick. Now that GC runs wait for `MemoryManager`, it can touch as many objects as it wants during a tick without paying a performance penalty.

While working on this change I came across a number of issues that should probably be addressed in the future:

1) Objects like Server, World and Player that can't possibly be GC'd repeatedly end up in the GC root buffer because the refcounts fluctuate frequently. Because of the dependency chains in these objects, they all drag each other into GC, causing an almost guaranteed parasitic performance cost to GC. This is discussed in php/php-src#17131, as the proper solution to this is probably generational GC, or perhaps some way to explicitly mark objects to be ignored by GC.
2) World's `blockCache` blows up the GC root threshold due to poor size management. This leads to infrequent, but extremely expensive GC runs due to the sheer number of objects being scanned. We could avoid a lot of this cost by managing caches like this more effectively.
3) StringToItemParser and many of the pocketmine\data classes which make heavy use of closures are afflicted by thousands of reference cycles. This doesn't present a major performance issue in most cases because the cycles are simple, but this could easily be fixed with some simple refactors.
2024-12-15 16:26:39 +00:00
2024-12-09 16:44:07 +00:00
2024-12-09 16:51:41 +00:00
2022-03-09 16:28:38 +00:00
2021-11-30 01:16:28 +00:00
2024-12-02 00:40:55 +00:00
2023-11-10 16:27:57 +00:00
2022-08-16 17:22:22 +01:00


A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP

CI GitHub release (latest SemVer) Discord
GitHub all releases GitHub release (latest by SemVer)

What is this?

PocketMine-MP is a highly customisable server software for Minecraft: Bedrock Edition, built from scratch in PHP, with over 10 years of history.

If you're looking to create a Minecraft: Bedrock server with custom functionality, look no further.

  • 🧩 Powerful plugin API - extend and customise gameplay as you see fit
  • 🗺️ Rich ecosystem and large developer community - find plugins easily and learn to develop your own
  • 🌐 Multi-world support - offer a more varied game experience to players without transferring them to other server nodes
  • 🏎️ Performance - get 100+ players onto one server (depending on hardware and plugins)
  • ⤴️ Continuously updated - new Minecraft versions are usually supported within days

PocketMine-MP is NOT a vanilla Minecraft server software.

It is poorly suited to hosting vanilla survival servers. It doesn't have many features from the vanilla game, such as vanilla world generation, redstone, mob AI, and various other things.

If you just want to play vanilla survival multiplayer, consider using the official Minecraft: Bedrock server software instead of PocketMine-MP.

If that's not an option for you, you may be able to add some of PocketMine-MP's missing features using plugins from Poggit, or write plugins to implement them yourself.

Getting Started

Community & Support

Join our Discord server to chat with other users and developers.

You can also post questions on StackOverflow under the tag pocketmine.

Developing Plugins

If you want to write your own plugins, the following resources may be useful. Don't forget you can always ask our community if you need help.

Contributing to PocketMine-MP

PocketMine-MP accepts community contributions! The following resources will be useful if you want to contribute to PocketMine-MP.

Donate

PocketMine-MP is free, but it requires a lot of time and effort from unpaid volunteers to develop. Donations enable us to keep delivering support for new versions and adding features your players love.

You can support development using the following methods:

  • Patreon
  • Bitcoin (BTC): 171u8K9e4FtU6j3e5sqNoxKUgEw9qWQdRV
  • Stellar Lumens (XLM): GAAC5WZ33HCTE3BFJFZJXONMEIBNHFLBXM2HJVAZHXXPYA3HP5XPPS7T

Thanks for your support!

Licensing information

This project is licensed under LGPL-3.0. Please see the LICENSE file for details.

pmmp/PocketMine are not affiliated with Mojang. All brands and trademarks belong to their respective owners. PocketMine-MP is not a Mojang-approved software, nor is it associated with Mojang.

Languages
PHP 99.9%