FS#4526 - Slowly degrading performance

Attached to Project: OpenTTD
Opened by Simon Smith (Simons_Mith) - Sunday, 20 February 2011, 17:15 GMT
Last edited by Remko Bijker (Rubidium) - Friday, 13 May 2011, 20:09 GMT
Type Bug
Category Core
Status Closed
Assigned To No-one
Operating System Mac OS X
Severity Low
Priority Normal
Reported Version 1.1.0-RC1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


I set up a 2048x2048 game with maximum AIs and the most expensive settings for construction, fewest industries and towns, etc. As each AI loaded I gave it 10,000,000 and let it get on with it. I ran practically the entire game at fast-forward speed. Had about 4 bankruptcies from AIs getting over-enthusiastic, (and my own company, which never lifted a finger); all were then replaced with other AIs later, giving 14 AIs in the end. The game ran (in a single session without quitting and restarting) from 1950 to 1973. As time went on, performance got slower and slower; around 8 seconds per day in the late 60s, sometimes approaching minutes per day at the point I gave up. The system was overloaded enough that the music occasionally became choppy towards the end, and there were several times when it appeared completely frozen (even the mouse pointer). When I paused, there was a noticeable speed up but towards the end even scrolling about the map was a bit chuggy.

After the final game save, quitting the game took a good 5-10 minutes before OpenTTD had managed to fully shut itself down.

After a restart, reloading the 1973 save, performance has immediately returned to acceptable levels for the number of active vehicles and AIs.

This is a 2GHz iMac (OS 10.5.8) with 1Gb RAM, and I don't really know what performance I ought to expect from an experiment like this. But given the dramatic speed-up after a reload I thought I'd report it.
This task depends upon

Closed by  Remko Bijker (Rubidium)
Friday, 13 May 2011, 20:09 GMT
Reason for closing:  Unreproducible
Comment by Remko Bijker (Rubidium) - Sunday, 20 February 2011, 18:23 GMT
Smells to me like an AI that is doing something "stupid". It might, for example, construct a huge state of some sorts using lots of memory, and then it keeps iterating through that state causing massive swapping.

It would become really interesting when it happens without AIs, otherwise it's (in my opinion) an AI bug which means that someone has to figure out which AI is actually causing it, and possibly adding some more limitations to OpenTTD to prevent these kinds of things to happen. Although... each limitation can probably be exploited in some way or another.
Comment by Simon Smith (Simons_Mith) - Sunday, 20 February 2011, 19:29 GMT
Good point. That does seem the most likely explanation. I'll retry with various combinations of AIs, see if I can narrow it down. Probably going to be time-consuming, but hopefully I'll have a followup in a few weeks.