Page 1 of 1
Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 07:23
by burli
As far as I know games like minetest are more limited to the CPU than the GPU. Thats why I am a little bit disappointed, because just 50% of my quadcore CPU is used. I know that multithreading is not that easy, but it could improve the game.
I tryed num_emerge_threads = 2/3/4, but it has no effect to the performance or the CPU load.
Are there any plans for that?
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 09:45
by Calinou
num_emerge_threads sets the number of threads to use for C++ map generation only, it won't affect mods and other areas of the engine.
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 10:34
by gregorycu
I'm always looking for ways to improve performance in ways that has the most positive impact on end users.
A question, are you noticing poor performance? Or are you just noticing minetest is not using 100% CPU?
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 10:57
by burli
gregorycu wrote:A question, are you noticing poor performance? Or are you just noticing minetest is not using 100% CPU?
Well, if the game get's more content, like more plants, the performance drops. If you are just walking and a few blocks ahead is nothing because the mapgen lacks, thats annoying.
I don't have high end hardware, but a quad core with 16GB of RAM and a Nvidia GTX750 should be enough to run MT acceptable
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 14:39
by sofar
You're saying that minetest is taking 50% of your CPU. That's likely 50% of one core. If you'd split that workload to multiple cores, then that would still consume (in total) the exact same amount of CPU cycles, but it would require extra locks, and those are expensive, and generally make performance worse.
So, making things more parallel isn't always better for performance.
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 15:09
by burli
I say, the CPU runs at 200% (or less) of 400%. Highest value I ever saw was 240%, so I guess there are more than 2 tasks right now.
I know that it could be tricky to deal with threads. But one suggestion might be to use LevelDB instead of SQLite. As far as I know all operations are asynchronous. So LevelDB could run as task, if it is not already doing.
And I think, the Mapgen and Lua are the bottlenecks. I don't know exactly how Mapgens work, but maybe each mapchunk can be generated in a separate task. I don't know how much nodes are connected to the neighbors
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 16:04
by sofar
Mapgen is already a separate thread. There are two mapgen threads to start by default.
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 16:17
by rubenwardy
sofar wrote:Mapgen is already a separate thread. There are two mapgen threads to start by default.
[citation needed]
As far as I know, mapgen is done on the server thread as we need to support lua mapgens.
The emerge thread is for other things, I think it is for sending blocks to clients, not sure.
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 17:54
by sofar
rubenwardy wrote:sofar wrote:Mapgen is already a separate thread. There are two mapgen threads to start by default.
[citation needed]
As far as I know, mapgen is done on the server thread as we need to support lua mapgens.
The emerge thread is for other things, I think it is for sending blocks to clients, not sure.
ah, yes, you're correct. emerge threads are for loading, compressing and sending mapblocks to clients.
Re: Better support for multicore CPUs

Posted:
Thu Apr 07, 2016 18:20
by burli
Thread doesn't necessarily mean, that this thread runs on another core. Didn't look at the code
Re: Better support for multicore CPUs

Posted:
Fri Apr 22, 2016 12:51
by Fixerol
A question, are you noticing poor performance? Or are you just noticing minetest is not using 100% CPU?
IIRC, minetest does not have true multicore support, it mostly uses 1 CPU, for example my CPU load is 25% (on 4 cpu logical cores).
Re: Better support for multicore CPUs

Posted:
Fri Apr 22, 2016 13:08
by burli
If you play in singleplayer 2 cores are used. One for server, one for client