Page 1 of 1

[0.14.0][MP] Terribly slow saving of game

Posted: Fri Aug 26, 2016 9:51 pm
by yfcz
Hello,
I'm not sure if I should to write this as bug report or feature request as it could be placed in both categories.

I have server with quite low main memory, here specs of the server:
CPU: 1 core of Intel Xeon CPU E5-2650 v3 @ 2.30GHz
Main memory: 1 GB
HDD: fast modern SSD

Factorio's server runs pretty smooth on such server except one situation — saving game. Saving game takes over one minute which is terribly long.
The problem is you cannot play until saving is finished.

It seems that some memory-intense work is done using swap space instead of main memory. During saving I see that ~130 MB is constantly read and 20 MB is constantly saved to swap.
Swap space is used most probably due to full main memory.

-----------------

So the question is there any viable way to optimize saving?
Add possibility for incremental saves?
Add possibility to disable auto-saves when players connects?

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Fri Aug 26, 2016 10:04 pm
by Loewchen
Considering the little amount of memory of the server, this is not unexpected behaviour. It might improve slightly with new save file size reducing methods in the future but in general you should consider switching to a more capable machine.
NaB.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Fri Aug 26, 2016 10:15 pm
by orzelek
You can try using undecorator mod. It helped someone with memory usage on headless server so might alleviate the problem for some time until save increases again.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Fri Aug 26, 2016 11:10 pm
by yfcz
Loewchen wrote:Considering the little amount of memory of the server, this is not unexpected behaviour. It might improve slightly with new save file size reducing methods in the future but in general you should consider switching to a more capable machine.
NaB.
If you don't consider it as bug, move it to „Ideas and Suggetions“ instead to „Not a bug“, please.

--------

In my case buying more memory is not an option for me since I rent that server as service for 1 € per month.
Server with 2 GB of main memory costs 5x more. That high price is no-go for me.

And it's not just me. Imagine if price 1 € per month would be fully sufficient to run Factorio server. It would allow much wider audience to run servers if one can keep operating costs radically low.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Sat Aug 27, 2016 4:35 am
by Rseding91
Factorios minimum system requirements is 2 GB of RAM and even then that's the minimum. If your save file grows you will need more.

There's no bug here.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Sat Aug 27, 2016 7:14 am
by DaveMcW
Purchase Page wrote:System requirements for running the game are: 1GB RAM, 512MB dedicated video memory.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Sat Aug 27, 2016 4:34 pm
by Rseding91
DaveMcW wrote:
Purchase Page wrote:System requirements for running the game are: 1GB RAM, 512MB dedicated video memory.
Well that's wrong... It needs to be updated to match what steam says.

[0.14.1] Save-game progress bar doesn't show progress

Posted: Sat Aug 27, 2016 8:56 pm
by yfcz
Hello,

currently it takes around six minutes to save game on my server.
During first two minutes it is showing empty (0 %) progress bar. Last two minutes it is showing full progress bar (100 %). Using resource monitor I verified that game is doing some memory-intense stuff during these times.

It confuses connecting players and makes them think that server is not working properly.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Sat Aug 27, 2016 9:08 pm
by posila
Can you provide your save so we can investigate its memory usage?

Re: [0.14.1] Save-game progress bar doesn't show progress

Posted: Sat Aug 27, 2016 9:10 pm
by Rseding91
six minutes is insane.. can you upload the save file?

The longest I've ever seen a save file take to save is 4 seconds.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Mon Aug 29, 2016 7:52 pm
by yfcz
posila wrote:Can you provide your save so we can investigate its memory usage?
With save attached to this post it takes around 6 minutes to save game.

iotop shows something like 100 MB average read and 30 MB average write by Factorio process from/to swap space during saving.
If I do approximate calculation it goes like this:
6 m * 60 s * 100 MB = 36 000 MB read from swap
6 m * 60 s * 30 MB = 10 800 MB written to swap

That's a lot of data. :shock:

---------------

I found workaround.
1) I processed map by orzelek's UnDecorator mod (removed details on the map)
2) I removed all items lying on the ground (huge number of alien artifacts).

These two things together (one is not enough) temporary decreased save time from six minutes to ten seconds. One day passed and saving takes like two or three minutes again (big par of map has been discovered by players).

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Mon Aug 29, 2016 8:03 pm
by Loewchen
Merged and reopened.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Mon Aug 29, 2016 8:19 pm
by Rseding91
How much memory are you giving to the process? It sounds like it ran out of RAM a long time ago and is constantly swapping to the disk.

It takes 5 seconds to save the game when I test it on my computer.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Mon Aug 29, 2016 8:25 pm
by yfcz
Loewchen wrote:Merged and reopened.
I believe these two merged topics are unrelated.

One is about poor performance. The other is about progress bar.

It might look that there might be same cause of these two problems, but I doesn't looks like to me. I believe that performance issue described at „progress bar topic“ just helped to make wrong behavior of progress bar much more obvious (but it is not its cause).

Why? Even if loading is pretty fast (ten seconds) I see that at the beginning and the end of saving there are periods when progress bar is not updated. These periods are just much shorter and therefore harder to spot.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Mon Aug 29, 2016 8:34 pm
by yfcz
Rseding91 wrote:How much memory are you giving to the process? It sounds like it ran out of RAM a long time ago and is constantly swapping to the disk.
There is 1 GB of physical memory available and 4 GB of swap space available.

When game is running and NOT saving it consumes around 700 MB (70 %) of physical memory and 1,7 GB (less than 50 %) of swap space.
Memory usage is the same when game IS saving.

Also when game is NOT saving I just see little bursts of data (few kB up to few MB per few secods) are read/written from/to swap space. When game is NOT saving amount of IO operations related to swap space tend to be very low.
Rseding91 wrote:It takes 5 seconds to save the game when I test it on my computer.
Same on my desktop.

Re: [0.14.0][MP] Terribly slow saving of game

Posted: Tue Aug 30, 2016 1:32 pm
by Klonan
yfcz wrote:
Rseding91 wrote:How much memory are you giving to the process? It sounds like it ran out of RAM a long time ago and is constantly swapping to the disk.
There is 1 GB of physical memory available and 4 GB of swap space available.

When game is running and NOT saving it consumes around 700 MB (70 %) of physical memory and 1,7 GB (less than 50 %) of swap space.
Memory usage is the same when game IS saving.

Also when game is NOT saving I just see little bursts of data (few kB up to few MB per few secods) are read/written from/to swap space. When game is NOT saving amount of IO operations related to swap space tend to be very low.
Rseding91 wrote:It takes 5 seconds to save the game when I test it on my computer.
Same on my desktop.
Minimum requirements are 2GB of ram,

If you can reproduce the issue on a machine which meets the minimum specs please make another bug report