-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implement pocketmine\world\format\SubChunk natively #24
base: master
Are you sure you want to change the base?
Conversation
I think this is now functionally OK, but it needs to be thoroughly covered by tests before merge. The following things should be tested:
|
layer->container.collectGarbage(false, 0); | ||
|
||
bool keep = false; | ||
for (auto p : layer->container.getPalette()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is stupid as per pmmp/PocketMine-MP#6574, although the impact here is less than in PHP
The serialize code should be simplified. I've always hated doing it this way. |
Since SubChunk is final (or should be), there's clear bounds on its functionality.
Since all the types of its fields are also sealed, we can safely assume that the PHP method wrappers of PalettedBlockArray and LightArray won't be overridden. This means it's possible to avoid calling hot methods like PalettedBlockArray::get() via the Zend VM, and instead directly call their C++ counterparts without going through PHP. This eliminates 1 function call for hot functions like
SubChunk::getFullBlock()
andSubChunk::setFullBlock()
.A quick performance test using this code:
yields the following results on Windows, PHP 8.0.8 (release), JIT=off:
compared to:
This shows a performance improvement of approximately 60%, with throughput improved by 2.5x.