The International Simutrans Forum

 

Author Topic: Simutrans Process stuck and consumes 100% CPU  (Read 4265 times)

0 Members and 1 Guest are viewing this topic.

Offline tuxianer1988

  • *
  • Posts: 39
Simutrans Process stuck and consumes 100% CPU
« on: May 15, 2011, 06:52:20 PM »
Hey guys,

I am playing a Server Game of Simutrans together with a friend. We are now playing for over 2 months. Since yesterday we encounter problems. The simutrans process on the server consumes 100% of CPU and a connection cannot be established.

We run under Version 110-0, I thus updated today to the version 110-0-1 which is currently stable. But the same thing happen ! Can somebody tell me where this problem might be rooted ! If you have any further questions or need further details like hardware, savegame size etc. please feel free to ask :)

Regards and many thanks in advance

Torsten


Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #1 on: May 15, 2011, 07:10:52 PM »
If the CPU is really outmaxed (too many passengers and trains etc.) then the server willstart lagging and no connections can be established. But it could be as well an error in the savegame. Does the download still works or any connection attempts fail? If the latter is the case, the server savegame may be corrupt. In that case just upload your last successful clientsavegame to the server (in your simutransfolder, if you did not connect to other clients in between). It should have the name "client1_network.sve" or even some higher number. Copy it into your svae folder and laod it in SImutrans. If it loades, you can transfer is to the server, rename it server13353-network.sve (there should be already a game with this name on the server).

Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #2 on: May 15, 2011, 07:18:17 PM »
Hey prissi,

the server accepts connections until some time. I just had this 30 minutes after I started the process again. I could join the game do some staff and at some point the window stuck and I see on the console that the processes runs 100% and "stuck".

Does this help you ? I think it is case a) of your scenarios...

Regards

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #3 on: May 15, 2011, 08:24:22 PM »
If it is point A only very little can be done about it. Just two things:

First, start the map with 6 FPS per command line option on the server. Try locally, if this option works. If not, save the game locally as 99.17 or 100.0 or so and then it will work.

Trees and movingobjs also consume some time, as well as pedestrians. Switch them off, which can be done either per simuconf.tab or localls and then saving again. Trees and movingobjects (and citycars) can be reomoved, by removing all those objects from the pak folder, loading/saving the game and then putting them back.

If this not helps you any further, you need a faster server ... Although I am very interesting in the savegame, as we always need CPU consuming testgames for profiling.

Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #4 on: May 16, 2011, 08:02:39 AM »
Hey prissi,

thanks for your answer. I have just some follow up questions.

1) How can I inset the 6 FPS add to the running server instance. I will then start the server, save the game, and restart the server with the "new" savegame in order to activate the new options.

2) If 1) does not word than I will remove the pedestrians lets see wether it helps.

Just some facts of the savegame:

1.000.000 Inhabitans
1500-1600 vehicles (cars, trains, ships and planes)
appro. 1300 stations
2 Players

Server:

1 GB RAM
2,45 GHz Pentium IV

We ware playing the pak64.german with some addons (atomic power plant, and some food industry from pak64).

Thanks for your help, give me just a small hint wether I understand you and your suggested proceedings right.

Regards
« Last Edit: May 16, 2011, 08:18:10 AM by tuxianer1988 »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #5 on: May 16, 2011, 12:07:34 PM »
I would first start the server with "-fps 6" added to the command line. If this not work, you may have to need to modify this locally, i.e. start on the commandline with "-fps 6" as a local game. This should override the game setting.

Pedestrians can take up to 10% of the CPU, same for citycars; pedestrian especially, when the list of objects is very long, as to remove a pedestrian the whole list of moving stuff must be searched. (On local games prthashtables help a lot, but those work not easily across architectures as the internal order is not preserved.)
Movingobj and trees are also not really important, especially the first can eat a little CPU (depending on their density).

But most CPU is from routing in later games, or from checking if the next tile is free from convois, or from processing the list of all vehicles (which is done at least every frame). Not much can be done about that but dropping the frame rate a little.

So just add to simuconf.tab for server games:
Code: [Select]
# no pedestrians
random_pedestrians = 0
stop_pedestrians = 0

# show very little random moving animals (n = every n suited tiles, default 1000)
random_wildlife_probability = 100000

# How many frames per second to use? Display may look pretty until 10
# (much lower can run into troubles)
frames_per_second = 6

Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #6 on: May 16, 2011, 12:29:24 PM »
Hey prissi,

thanks for the advice, it seems that, locally, the game now runs smoothly. With the 6 fps and the other suggested ideas.

For some reaon I still see pedestrians. Even though I changed the configuration AND saved the game and reloaded it. Do you know why these small anoying guys do not wanna go :D ? Oh AND there are still these stupid cars .... For some reason it does not accept my configuration changes.

Regards

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #7 on: May 16, 2011, 08:37:45 PM »
To get rid of pedestrians: Go to the setting options and disable them before saving locally.

To get rid of all cars: Remove all citycars.*.pak (likely citycar.stadtauto.pak for pak.german) and load the game, save it, put citycar.*.pak back. Should remove all citycars.

Otherwise you can save your game under previous versions. Load it, select new world, set savegameversion to 99.17. This will reset all network stuff including passwords etc. In the settings just change whatever you like, then close new world and save the game. Close simutrans, edit simuconf.tab, and load it. The missing entries (like pedestians etc.) will be taken from simuconf.tab.

Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #8 on: May 18, 2011, 06:15:00 AM »
Hey prissi,

it is all too bad. I did not everything you mentioned except for the city cars. I removed all pedestrians -> server process still stucks at 100%

I saved the savegame as an older version -> server process still stucks after a few minutes !

Anything else how I can geht my game back :(

Regards

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #9 on: May 18, 2011, 08:15:28 AM »
You can play it locally, i.e. set the server as your home computer and the other connects to it.

But sent me the savegame, it is very hard to say what actually is the problem. It may as well be a bug. Otherwise I am down to generic statements like if you have many ships, you can try to set some waypoints for ships, which may help.


Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #10 on: May 18, 2011, 11:37:27 AM »
Okay I uploaded it to my Space:

here you find the modified pak64.german we are using:

http://simutrans-germany.com/files/upload/pak64.german.zip

Savegame:

http://simutrans-germany.com/files/upload/server_newer.sve

Thanks in Advance ! This should be the latest savegame !

Regards

« Last Edit: May 18, 2011, 03:27:45 PM by tuxianer1988 »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #11 on: May 18, 2011, 10:24:14 PM »
Its is a bug:
in simverkehr.cc replace lines 644 by the following:
Code: [Select]
uint8 number_reversed = 0;
while(  number_reversed<2  ) {
const grund_t *test = welt->lookup(checkpos);
if(!test) {
// should not reach here ! (z9999)
break;
}
const uint8 next_fahrtrichtung = ribi_typ(dir);
const uint8 nextnext_fahrtrichtung = ribi_typ(dir);
// test next field after way crossing
if(no_cars_blocking( test, NULL, next_fahrtrichtung, nextnext_fahrtrichtung, nextnext_fahrtrichtung )) {
return false;
}
// ok, left the crossint
if(!test->find<crossing_t>(2)) {
// approaching railway crossing: check if empty
crossing_t* cr = gr->find<crossing_t>(2);
return cr->request_crossing( this );
}
else {
// seems to be a deadend.
if(  (test->get_weg_ribi(road_wt)&next_fahrtrichtung) == 0  ) {
// will be going back
pos_next_next=get_pos();
// check also opposite direction are free
dir = -dir;
number_reversed ++;
}
}
checkpos += dir;
}

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #12 on: May 18, 2011, 10:31:20 PM »
This was actually due to lots of strange crossings around 253,313 ...

Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #13 on: May 19, 2011, 06:28:55 AM »
This is awesome, it does work. This is just great !!! Can you just tell me what kind of "strange" crossings there were ?

If I can contribute this way something to this great ! game I am happy :)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #14 on: May 20, 2011, 01:09:14 PM »
Well you had lots of sandrail on a road (How the hell you managed this?) => crossings in the direction of the road. A vehice checks until next crossing if a railroad crossing is free. If the road ends, it turn back. However there was one stretch of roads where always was a crossing => endless loop as check bounces forward and backward.

Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #15 on: May 20, 2011, 01:15:31 PM »
I know that, this was an error as I updated to the new pak64.german from a modified pak.german of paco_m. If I remove all the sand tracks on the road I got a segfault which is also not good.

So I do not know how to get them away. (In the old pak it WAS a tram) but after the upgrade it brokes as you see :( Any idea how to get ride of these ?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9409
  • Languages: De,EN,JP
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #16 on: May 21, 2011, 12:11:12 AM »
No easy way; did you try touse the rail removal tool for removal. That should work; crashing should be another error one schoul look at ...

Offline tuxianer1988

  • *
  • Posts: 39
Re: Simutrans Process stuck and consumes 100% CPU
« Reply #17 on: May 21, 2011, 06:13:19 AM »
Got it !

If you remove the tracks/streets with the normal removal tool ! The thing is that there should no cars be in the closer area (due to the routing ?). If there are cars in the closer area than I got a segfault. Not I removed step by step all the bad field and now it is clean ! Without any further error !!!!

Thanks I hope that now the games runes soomethly as simutrans always does again :)