minetest-mapserver / mapserver

Minetest realtime mapserver, written in go
Other
101 stars 22 forks source link

Performance on servers with weak cpu #93

Closed heavygale closed 3 years ago

heavygale commented 4 years ago

My server has only a weak cpu and is already busy with minetest itself. Is it possible to specify that changes in the game world per mapblock are only applied for example every five minutes? Can this be achieved by setting expiretime to five minutes? (expiretime and purgetime are not described in the configuration)

Any idea how i can find out which blocks on my server are constantly being changed? No player was connected during the night and yet mapblocks were rendered continuously. Since my server only has a weak CPU, this alone causes a base load of about 20% on the server. There are no force_loaded blocks, at least not according to force_loaded.txt

grafik

By the way, this project is really awesome, thanks for that!

BuckarooBanzay commented 4 years ago

My server has only a weak cpu and is already busy with minetest itself. Is it possible to specify that changes in the game world per mapblock are only applied for example every five minutes? Can this be achieved by setting expiretime to five minutes? (expiretime and purgetime are not described in the configuration)

Running the mapserver should even be possible on a Raspberry Pi (2+) Are you sure the initial rendering (of the whole world) is done? It should say so in the console log.

The expiretime and purgetime settings are only to hold back mapblocks in-memory so the database doesn't have to be queried the whole time.

There isn't (yet) a setting for the incremental rendering loop, it defaults to 5 seconds currently:

https://github.com/minetest-mapserver/mapserver/blob/06cc766986c9cb1908694ab33b8e750b6b16bfa1/tilerendererjob/incremental.go#L34

I could add a setting for that if thats the problem...

Any idea how i can find out which blocks on my server are constantly being changed? No player was connected during the night and yet mapblocks were rendered continuously.

Thats odd, maybe you gets some infos if you start the mapserver with mapserver -debug

By the way, this project is really awesome, thanks for that!

Thanks

heavygale commented 4 years ago

Are you sure the initial rendering (of the whole world) is done?

Yes, it took two days for my 11GB postgresql database (the limiting factor was the hard disk speed). It's a small vServer, only 1GB Ram, slow HDD, two slow CPUs - probably a bad choice for a minetestserver. The mapserver performance isn't the problem, the slow server is.

The regular log output currenty (no player connected) looks like this:

time="2020-04-14T11:01:35Z" level=info msg="incremental rendering" elapsed=1.704932678s lastMtime=1586862093356 mapblocks=11 tiles=24
time="2020-04-14T11:01:42Z" level=info msg="incremental rendering" elapsed=1.633745718s lastMtime=1586862097413 mapblocks=11 tiles=24
time="2020-04-14T11:01:43Z" level=info msg="incremental rendering" elapsed=905.135309ms lastMtime=1586862102100 mapblocks=1 tiles=12
time="2020-04-14T11:01:45Z" level=info msg="incremental rendering" elapsed=1.989351196s lastMtime=1586862102730 mapblocks=10 tiles=24

I've started the mapserver docker container with debug parameter and you can find the log for one incremental rendering loop here.

I don't have the time to further look into it right now, but I'll check the stated coordinates later today.

I could add a setting for that if thats the problem...

A setting for this would be nice. Even If it's not used to optimize performance, some people may want to only create a daily updated image.

BuckarooBanzay commented 4 years ago

A setting for this would be nice. Even If it's not used to optimize performance, some people may want to only create a daily updated image.

I've added a configuration field for the update-intervals: incrementalrenderingtimer https://github.com/minetest-mapserver/mapserver/commit/9d610681d0fd8deb4bc73ea97787dd6b9a69b9f6

This should appear if you run the latest version of the docker image and defaults to 5s but accepts a duration string (https://golang.org/pkg/time/#ParseDuration, for example 24h)

See: https://github.com/minetest-mapserver/mapserver/blob/master/doc/config.md

I've started the mapserver docker container

:heart: :whale:

Yes, it took two days for my 11GB postgresql database (the limiting factor was the hard disk speed). It's a small vServer, only 1GB Ram, slow HDD, two slow CPUs - probably a bad choice for a minetestserver. The mapserver performance isn't the problem, the slow server is.

This seems reasonable for a minetest-server, depending on the mods used though...

About the mods and the forceload thing: Which server is it and what are the mods on it? I suspect some area-loading-shenanigans :smile: Tubelib, advtrains and co can load and modify mapblocks without explicitly forceloading them...

heavygale commented 4 years ago

I've added a configuration field for the update-intervals

Thank you, that already helps - I've set it to 60s for now and I think I can keep it running like this without affecting the ingame performance (see difference 1 to 4).

grafik

The server is minetest.boolshit.de:30001 and it's running since 2014 with a lot of mods (mostly passive mods like additional blocks/ores) and there are only a few player regularly playing. The mapserver is running here. All installed mods are listed in the website, some of them are no longer updated but I can't remove them because there would be a lot of unknown blocks/objects in the world. advtrains might be a good guess, I just added this mod lately.

Elinvention commented 4 years ago

I have the same issue with incremental rendering. It could be advtrains, because trains keep going even if no one is connected and it's just routes being set that trigger an incremental rendering. This wastes a lot of CPU... I wonder if advtrains could be stopped when not needed.

BuckarooBanzay commented 4 years ago

@Elinvention you can try to tune it with the

and the

A more CPU- and RAM-Conserving config would look something like this:

{
 "renderingfetchlimit": 500,
 "renderingjobs": 1,
 "incrementalrenderingtimer": "30s",
 "mapblockaccessor": {
  "expiretime": "10s",
  "purgetime": "15s",
  "maxitems": 200
 }
}

This will fetch renderingfetchlimit (500) mapblocks every incrementalrenderingtimer (30 seconds) and render them in renderingjobs (1) thread.

The caching is also dialed down in this example (if you have OOM-problems), the settings are all documented here: https://github.com/minetest-mapserver/mapserver/blob/master/doc/config.md

Let me know if you have issues here or on IRC ("BuckarooBanzai" on #freenode) or on Discord (BuckarooBanzai#6742)

EDIT: about the advtrains issue:

I wonder if advtrains could be stopped when not needed.

I'm having the same Problem with that mod (it does not scale well), but i think that should be solved on the advtrains side...

BuckarooBanzay commented 4 years ago

I wonder if advtrains could be stopped when not needed.

@Elinvention just a heads-up about the advtrains issue (offtopic but still): I managed to get good results with that mod: https://github.com/pandorabox-io/advtrains_custom It basically stops all calculations for trains outside of a 500 nodes radius around connected players.

We had 120ms per second usage in the advtrains mod before and after installing the advtrains_custom around 10ms per second.

Stats:

BuckarooBanzay commented 3 years ago

closing this, if there are more perf issues feel free to reopen/create a new issue