The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: laos on June 22, 2017, 05:11:57 AM

Title: game freezing when generating map
Post by: laos on June 22, 2017, 05:11:57 AM
I used to be able to generate relatively large maps on Windows, but as of the most recent nightly (6/21) and a few recent versions I've been unable to get the Large NE map (http://maps.simutrans.com/downloads/USA-NE-Large.zip) to render with the following settings:

Settings:
Starting Year 1940
1810 towns
60 big cities
10 clusters
250 cluster size
899 public buildings
899 industries
median population 6000
drives and signals on right

Climate:
water level -2
beach -2
dunes -2
plains - 1
lowlands 4
mountains 8

Game always hangs on a black screen for a very, very long time before either crashing or i give up on the map generation.

Is this just too big a map for the game? I've played maps in the past with relatively similar sizes, at least I think I have. They took a while to load but they did eventually succeed. I've failed to get any maps / save games working as everything crashes before that opportunity.
Title: Re: game freezing when generating map
Post by: jamespetts on June 22, 2017, 12:07:40 PM
I have just been able to generate a map with those settings, although it took a very long time (I went away and left it for about twenty minutes, and it had finished by the time that I got back). However, the resulting map is extremely dense with large towns: I suggest halving the number of towns for enhanced gameplay.

One thing that you did not specify, however, is the number of rivers. River generation can take a huge amount of time on a large map. I set it to generate 265 rivers; did you have yours at a higher setting?

I shall have to look into optimising/multi-threading map generation one day, as it does seem to be quite slow at present.
Title: Re: game freezing when generating map
Post by: laos on June 23, 2017, 06:10:53 AM
Quote from: jamespetts on June 22, 2017, 12:07:40 PM
I have just been able to generate a map with those settings, although it took a very long time (I went away and left it for about twenty minutes, and it had finished by the time that I got back). However, the resulting map is extremely dense with large towns: I suggest halving the number of towns for enhanced gameplay.

One thing that you did not specify, however, is the number of rivers. River generation can take a huge amount of time on a large map. I set it to generate 265 rivers; did you have yours at a higher setting?

I shall have to look into optimising/multi-threading map generation one day, as it does seem to be quite slow at present.

I had 128 rivers. I just tried with 1200 cities instead and still getting stuck on initializing map. I assume you're using Linux, not Windows?
Title: Re: game freezing when generating map
Post by: jamespetts on June 23, 2017, 10:11:20 AM
I use Windows at home and it was on Windows that I ran the test. May I ask what your specifications are and for how long that you left the map generation?

Edit: I have just re-run the creation of the map to your specifications, and I timed it at 20 minutes on my machine.

Edit 2: For reference, it is cities (at 55.18% of CPU time used) and rivers (at 25.49% of CPU time used) that are the most time consuming operations in generating new maps. I think that I have found a simple optimisation that may reduce CPU usage associated with cities on map generation by circa 10%, but this still needs testing. The long-term solution to this will be multi-threading river and city generation on map creation, but this will be a lot of work.
Title: Re: game freezing when generating map
Post by: DrSuperGood on June 23, 2017, 03:16:21 PM
Map generation is always a resource intensive process. It can take a minute or so to generate sizable maps in modern Civilization games as an example.

The best solution would be to keep the application responsive and inform the user that it has not crashed and is just taking a very long time. This could be in the form of a blinking text showing what it is currently generating, or preferably a counter of sorts showing how much is left to generate (eg "Generating cities: 113/1810").
Title: Re: game freezing when generating map
Post by: jamespetts on June 23, 2017, 03:52:55 PM
Thank you for those suggestions. There is a progress bar, but it tends to get stuck in certain places. I have identified a possibly substantial optimisation in the generation of towns in Extended that can be done relatively simply, but optimising river generation can probably only be done signficiantly by multi-threading, which would be a large task.
Title: Re: game freezing when generating map
Post by: laos on June 23, 2017, 03:53:35 PM
Quote from: jamespetts on June 23, 2017, 10:11:20 AM
I use Windows at home and it was on Windows that I ran the test. May I ask what your specifications are and for how long that you left the map generation?

Edit: I have just re-run the creation of the map to your specifications, and I timed it at 20 minutes on my machine.

Edit 2: For reference, it is cities (at 55.18% of CPU time used) and rivers (at 25.49% of CPU time used) that are the most time consuming operations in generating new maps. I think that I have found a simple optimisation that may reduce CPU usage associated with cities on map generation by circa 10%, but this still needs testing. The long-term solution to this will be multi-threading river and city generation on map creation, but this will be a lot of work.

i left the computer running overnight and it's still hanging on "initializing map"

PC is pretty powerful - 6700k, 32GB RAM, GTX 1080 - hence why i think it's a legitimate crash where something during the process is making the game crash, not that it's just taking a long time generate the map - CPU simutrans usage sits around 13% for a long time

I'm using http://bridgewater-brunel.me.uk/downloads/nightly/packages/Simutrans-Extended-Complete.zip plus the latest nightly .exe -- feel free to share other instructions if I am not using the proper steps/process for windows nightlies
Title: Re: game freezing when generating map
Post by: jamespetts on June 23, 2017, 08:48:10 PM
That is odd - I have not been able to reproduce an actual crash at all. The important thing for performance is your CPU, but yours seems as if it is likely to be at least as powerful as mine (and even if it is a laptop version, that would not account for it getting stuck if it is running overnight unless it has overheated so drastically as to cause it to scale back to a small fraction of its capability, which seems doubtful). Can you post screenshots of your settings to make sure that I reproduce them precisely?

Edit: I have now committed to Github a substantial optimisation of map generation. It still takes a while (as map generation generally is wont to do), but it should be faster than it was before. Can you re-test? I should be most grateful.
Title: Re: game freezing when generating map
Post by: laos on June 24, 2017, 04:25:33 PM
looks like it is significantly faster with map loading. Additionally I think an error on my end was causing full failure of map generation related to missing DLLs, so my apologies for not noticing this when discussing the bug earlier.
Title: Re: game freezing when generating map
Post by: jamespetts on June 24, 2017, 06:05:46 PM
Splendid - thank you very much for testing that!