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

Tree remover performance improvements #19

Open
CptCrispyCrunchy opened this issue Aug 20, 2016 · 1 comment
Open

Tree remover performance improvements #19

CptCrispyCrunchy opened this issue Aug 20, 2016 · 1 comment

Comments

@CptCrispyCrunchy
Copy link
Contributor

In dense forested area the game slows down significantly. Part of it is of course the bigger work for the BlockBufferSystem, but there are also improvements to be done when iterating over the trees and regions.

@skaldarnar
Copy link
Contributor

The block buffer utilized by the tree removal system blows up very fast, and thus the remove operations for placed blocks becomes very inefficient. Additionally, many blocks/block positions seem to be added multiple times.

I did some experiments with a new WorldProviderCore#setBlocks(Map<Vector3i, Block> blocks) (sets multiple blocks before marking chunks as dirty and notifying block changes) and the game was running pretty well. Each second up to 10.000 blocks were placed at once. Note that for each 10k blocks placed, 100k--300k blocks were removed from the buffer.

I will prepare a PR for discussing the setBlocks method soonish.

BlockBuffer size befor: 5850616, Placed: 10000, Removed: 271589, BlockBuffer size after: 5579027
BlockBuffer size befor: 5579027, Placed: 10000, Removed: 203695, BlockBuffer size after: 5375332
BlockBuffer size befor: 5375332, Placed: 10000, Removed: 263751, BlockBuffer size after: 5111581
BlockBuffer size befor: 5111581, Placed: 10000, Removed: 217213, BlockBuffer size after: 4894368
BlockBuffer size befor: 4894368, Placed: 10000, Removed: 212638, BlockBuffer size after: 4681730
BlockBuffer size befor: 4681730, Placed: 10000, Removed: 233951, BlockBuffer size after: 4447779
BlockBuffer size befor: 4447779, Placed: 10000, Removed: 232042, BlockBuffer size after: 4215737
BlockBuffer size befor: 4215737, Placed: 10000, Removed: 114511, BlockBuffer size after: 4101226
BlockBuffer size befor: 4101226, Placed: 10000, Removed: 202163, BlockBuffer size after: 3899063
BlockBuffer size befor: 3899063, Placed: 10000, Removed: 202152, BlockBuffer size after: 3696911
BlockBuffer size befor: 3696911, Placed: 10000, Removed: 155404, BlockBuffer size after: 3541507
BlockBuffer size befor: 3541507, Placed: 10000, Removed: 195616, BlockBuffer size after: 3345891
BlockBuffer size befor: 3345891, Placed: 10000, Removed: 165597, BlockBuffer size after: 3180294
BlockBuffer size befor: 3180294, Placed: 10000, Removed: 215912, BlockBuffer size after: 2964382
BlockBuffer size befor: 2964382, Placed: 10000, Removed: 207713, BlockBuffer size after: 2756669
BlockBuffer size befor: 2756669, Placed: 10000, Removed: 303665, BlockBuffer size after: 2453004
BlockBuffer size befor: 2453004, Placed: 10000, Removed: 90697, BlockBuffer size after: 2362307
BlockBuffer size befor: 2362307, Placed: 10000, Removed: 226325, BlockBuffer size after: 2135982
BlockBuffer size befor: 2135982, Placed: 10000, Removed: 279073, BlockBuffer size after: 1856909
BlockBuffer size befor: 1856909, Placed: 10000, Removed: 189065, BlockBuffer size after: 1667844
BlockBuffer size befor: 1667844, Placed: 10000, Removed: 270359, BlockBuffer size after: 1397485
BlockBuffer size befor: 1397485, Placed: 10000, Removed: 230114, BlockBuffer size after: 1167371
BlockBuffer size befor: 1167371, Placed: 10000, Removed: 296323, BlockBuffer size after: 871048
BlockBuffer size befor: 871048, Placed: 10000, Removed: 315524, BlockBuffer size after: 555524
BlockBuffer size befor: 555524, Placed: 10000, Removed: 318361, BlockBuffer size after: 237163
BlockBuffer size befor: 237163, Placed: 10000, Removed: 29973, BlockBuffer size after: 207190
BlockBuffer size befor: 207190, Placed: 7856, Removed: 207190, BlockBuffer size after: 0

Btw: asdf seems to be a good seed to test a city spawned inside a forest...

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

No branches or pull requests

2 participants