mojira.dev
MC-98994

Chunk Generation Performance Regressed by 20-30%

Since Minecraft 1.9, chunk generation performance has regressed by a substantial magnitude. This has been verified by both close inspection with a profiler, and also simply testing world generation with a fixed seed, whereby spawn initial spawn generation time increased from 4.19 seconds to 5.987 seconds between 1.8.8 and 1.9 (Vanilla). Using mc-dev names, but Vanilla code, the issue is as follows:

In 1.8, IChunkProvider, implemented by ChunkProviderServer contained two methods to get a Chunk. We call these getChunkAt and getOrCreateChunk. The names are a bit misleading since they both create a chunk if it does not exist, but essentially the main difference is the latter method did not remove a requested chunk from the unload queue. In 15w37a and subsequently 1.9, this method was removed. As a result of this, the World.getChunkAt method, called by the getBlock/setBlock methods had to be changed to use the getChunkAt (from the original getOrCreateChunk) method, which dropped any requested chunks from the unload queue.

Dropping these chunks from the unload queue is a very costly operation (ConcurrentHashMap.remove(....) called thousands of times a second), and the cause of this slowdown. To overcome this I have created a method called getOrCreateChunkFast that skips this unload queue drop. After verifying this change with a profiler it appears the issue is solved.

Patch: https://gist.github.com/md-5/13c4c0bd55fb00ee6eb1

Linked issues

Comments 26

We need your environmed: OS and Java version, and your graphics card drivers.

I allows me to post here, the problem is explained by MD_5, extremely serious.
I am owner of a Spigot Server 1.9, my players can not explored the map without creating powerful lag. My server has never suffers from lag before moving to 1.9, it is urgent to address this problem, especially as MD_5 has already preparation.

Mojang it really should worry about this problem that makes Minecraft experience in multiplayer unplayable and causes disgust.

I hope the problem will be resolved quickly. Thank you for your work.

@unknown that's not relevant to this report. This has nothing to do with a client. It's a developer to developer report, which we devs do not have an alternate tracker to report to so this is only place.

The java OS and drivers would be listed as "All"

I can confirm the above mentioned issues. And again can confirm this is not client related it is a serious issue with the game itself. Again another server where players CANNOT explore previosly un generated chunks as it causes major TPS and renders the server unplayable.

1.9.1 needed ASAP

Can agree with the comment above. Players cannot explore whatsoever, and it is an irritating issue to force them to stop when TPS goes dramatically low because of these unexplored chunks.

Please fix ASAP.

16 more comments

Scott Barnes - Keep it professional. He offered just as much substantiation as you did: none.

I do know it's a bad idea.

Minecraft servers operate on a 50ms tick rate. Network latency for any given client is going to be on average at least 100ms. Then add in round trip, processor lag on the client, delay between processing the network queues on the server, and then your suggested peer review.

Then factor in data synchronization, that the client then has to know more about data the server normally keeps to itself, increasing load and bandwidth on the network queue.

Now you're easily approaching 700 ms+ to do a single action that normally takes 1/10th of a millisecond.

This ticket is about how to modify a data structure to remove data when it no longer needs to be there. There's nothing a client can participate in logic about here.

This discussion ends here

@unknown well three things:

Firstly, see what happens when you think outside the narrowminded box - https://www.youtube.com/watch?v=JjSKqQI6Cr0&feature=youtu.be - you end up with moments like these.

Secondly, in 2008 had the same assnine response to how HD video can't work because of the roundtrip latency involved in clients negotiating between server<->client on how much CPU, GPU and Bandwidth can be consumed at intervals that reduces load on server/cloud infrastructure (and to prevent buffering)... oh...you now call this HD video online as a result of the team i was in via Microsoft (FYI we got it working to over 280million PC's during the beijing olympics and it was extremely rare you saw buffering symbols). Furthermore in SCADA style solutions where mission critical response times need to occur (think support operator staring at a screen looking for breakdowns) a 500ms-3 second response time for a visual catchup is undetected unless there's a deliberate interrupt in the users experience. So if an industrial grade emergency response solution like these can live with the existence of a 500ms - 3 in cognitive load to reactionary response... we can as well (assuming your limited theory on such matter were to come true, which it actuall wouldn't but this would involve an education process on threading, network latency compression etc etc)

The lifespan of a users behaviour at ahead-of-time chunk loading is as follows. The client makes the prediction ahead of time, generating chunks according to the intended seed/behaviour (and you can obfuscate the seed or encrypt that data better as well - but since MCP exists any client-side code is still open to hacking but there's more ways around that as well). While that client generates the behaviour client-side, it then sends back its findings BEFORE AND/OR AFTER the visual queue has been rendered or during such procedure.

All the server is doing is polling clients for verification of the truth, in that the clients return back the index associated within the Chunk with its findings, it then acts in the same capacity as Rendering nodes do in 3D rendering pipelines (you won't find this in your web developer textbooks btw, so may need to upgrade your Amazon account). The reality is the consequences vs likelihood of a client being without trust is actually lower than one would think, but just in case the server continues to apply verification protocols to ensure that the truth is always held to higher standard, in the event the truth fails and culprits are found it also can increase banning behaviour management whilst at the same time the server can then re-generate the suspicious chunk anyway only during non-peak-processing times.

That is to say, using crowd sourcing approaches you can furthermore generate chunks ahead of time while CPU's are idle, that is the client can tack onto the existing chatty packets that go between client/server that there are in a semi-idle state or what we called "refractory processing time", During this periods the server can predict players movements based on basic square root math(s) and historical data "User is x:1000,y:128, z:1000" therefore it can assume that another 1000 block radius is likely to be rendered in the next N amount of ticks, it can then ask spare CPU cycles to generate such information / data even if the user doesn't action that 1000 block radius. Keeping in mind its really a 1x time call per server per chunk ratio.

Lastly,
If i wanted a Wordpress blog update or fix, i'd respect your attempt at asserting authority, in the mean time, you play with your JavaScript/PHP toys and leave the hard thinking to the rest of us who look beyond what blind ignorant obedience has to offer.

As to how it relates to the topic at head.. simple... the chunk creation queue needs refactoring period. As all this does is put a band-aid upon a broken limb.

Can this please get assigned soon? It is still a massive problem.

Yay! You're the best, Mobius!

md_5

migrated

Community Consensus

Minecraft 1.9

Minecraft 16w15b

Retrieved