Better support for multicore CPUs

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Better support for multicore CPUs

by burli » Thu Apr 07, 2016 07:23

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?
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: Better support for multicore CPUs

by Calinou » Thu Apr 07, 2016 09:45

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.
 

gregorycu
New member
 
Posts: 3
Joined: Wed Jan 28, 2015 12:52
GitHub: gregorycu
IRC: gregorycu
In-game: gregorycu

Re: Better support for multicore CPUs

by gregorycu » Thu Apr 07, 2016 10:34

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?
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Better support for multicore CPUs

by burli » Thu Apr 07, 2016 10:57

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
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Better support for multicore CPUs

by sofar » Thu Apr 07, 2016 14:39

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.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Better support for multicore CPUs

by burli » Thu Apr 07, 2016 15:09

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
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Better support for multicore CPUs

by sofar » Thu Apr 07, 2016 16:04

Mapgen is already a separate thread. There are two mapgen threads to start by default.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Better support for multicore CPUs

by rubenwardy » Thu Apr 07, 2016 16:17

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.
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Better support for multicore CPUs

by sofar » Thu Apr 07, 2016 17:54

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.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Better support for multicore CPUs

by burli » Thu Apr 07, 2016 18:20

Thread doesn't necessarily mean, that this thread runs on another core. Didn't look at the code
 

Fixerol
Member
 
Posts: 633
Joined: Sun Jul 31, 2011 11:23
IRC: Fixer
In-game: Fixer

Re: Better support for multicore CPUs

by Fixerol » Fri Apr 22, 2016 12:51

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).
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Better support for multicore CPUs

by burli » Fri Apr 22, 2016 13:08

If you play in singleplayer 2 cores are used. One for server, one for client
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 6 guests

cron