BananaPuncher714 / Cartographer2

The best minimap plugin for Bukkit
48 stars 32 forks source link

High CPU with big Map #16

Closed BijuuKrunos closed 3 years ago

BijuuKrunos commented 3 years ago

Heyho, just wanted to ask if there is a way to have a realy big Map 20k x 20k not eating my cpu completely. everything ok with my RAM but the CPU is going extremely high. With my old config, my cpu was all the time over 800% and sometines a few thousands. Now its only between 300-400%. Here is my current config:

skip-ids:

Server Version: This server is running Paper version git-Paper-386 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT) thx for this amazing and hungry Plugin xD

BananaPuncher714 commented 3 years ago

You can try reducing chunk.cache-per-update to something smaller, like 1, and reduce chunk.update-delay to 2, so it processes 10 chunks per second. In addition, you can set reload-chunks to false in your minimap configs, which will prevent it from caching chunks that are already loaded. In addition, you can try setting render-delay to a higher value like 4, which will decrease the CPU usage especially if you have a lot of players using the minimap at the same time.

BijuuKrunos commented 3 years ago

Changed everything to your setting ideas. Does I need to restart or should a reload be enough? Just reloaded your plugin and there wasn't any noticable change. again 300% up to 450%. More Ideas haha?

not bad, have already created something with the changes so that, the server can keep the TPS stable. and 24 cores keep my back free.

BijuuKrunos commented 3 years ago

Okay, I Thought, that the cpu is just going higher for the first player using the map, just noticed that it is going higher for every player who is using the map. One Player 3-450% two Players ~800%. That is not good. should this be like that?

BananaPuncher714 commented 3 years ago

The good news is that it is not the chunk loading that is causing lag. The bad news is that it seems the main core cannot keep up with the rendering of the maps. Currently, the only solution is to increase the render-delay to something like 10, so that the map updates less.

BijuuKrunos commented 3 years ago

ahhh shit. do you think that there is a long term solution comming for this?

BananaPuncher714 commented 3 years ago

I'm not sure, but if you submit a timings report it would help greatly with identifying which parts of the code in particular are causing the lag.

BijuuKrunos commented 3 years ago

https://timings.aikar.co/?id=edd07ff797f1485fb93ef3a708d106bd

Hope this helps

BananaPuncher714 commented 3 years ago

Thanks. Cartographer doesn't look like it takes up more than 9ms per tick. There doesn't seem to be any tick loss, and the probably reason why your CPU is at 800% is probably because Cartographer does utilize multiple threads to render the map, which means your CPU is getting utilized more efficiently, rather than putting most of the load on one core. How many of your CPU cores actually reach 100%? Aside from that, in which situations does the TPS drop severely?

It's also a bit strange that one player manages to reach 450% CPU usage, especially when on my low end test server, CPU usage hardly increases more than 20%. What happens if you remove Spartan and React but keep Cartographer? Spartan is known for doing a lot of packet manipulation and doesn't show up in the timings. It may interfere with Cartographer depending on how it manages packets.

As for the source of lag in regards to Cartographer, it does appear that the renderer causes the greatest amount of lag. If increasing the render-delay in the config does not reduce the CPU usage, it is most likely some other plugin causing a compatibility issue of some sorts.

BijuuKrunos commented 3 years ago

There aren't cpu cores which reachs that much it is more like everyone is reaching 50-60% and the threads together are 400-800%... the TPS is dropping if enough players are using the map, like 3-5. Than the cpu load is by over 2000% and all the cores are nearly reaching 100%.

I will test, what happens if I am not using spartan and React and report you back. with the current config it is more like 200% CPU increase for every player who is using the map but only on this server with the 20k x 20k Map. On the other servers with smaller maps this problem is not ass noticable.

BijuuKrunos commented 3 years ago

Heyho, here is my timings report without React and Spartan active. There is not a realy big change. Hope this can help you.

https://timings.aikar.co/?id=f2272a5e16d648f796d11f2866841827#timings

BananaPuncher714 commented 3 years ago

Ok, thanks. I'll try to go over the renderer code to see if I can make it any more efficient.

BananaPuncher714 commented 3 years ago

It should be greatly improved with https://github.com/BananaPuncher714/Cartographer2/commit/b2a2907ef9b2ce86cc16d090cf643a792537d243. If it's still causing issues please report them. If there are no problems, I'll close this issue after a day. Thanks.