OpenTTD

Tasklist

FS#6145 - High CPU usage for ships with empty orders

Attached to Project: OpenTTD
Opened by Chu Chin Kuan (moogtrain) - Monday, 20 October 2014, 08:59 GMT
Type Bug
Category Vehicles
Status New
Assigned To No-one
Operating System All
Severity Medium
Priority Normal
Reported Version 1.4.3
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

The game would lag with 100% CPU usage on a single core when many ships with empty order lists are let to roam freely on large bodies of water. On my system (2.4GHz i5, 4GB RAM), having > 80 ships running freely on a body of > 500 tiles is enough to make the lag visible. Having more ships on the body of water OR having the ship on larger bodies of water _ would cause the game to lag even more.

Steps to reproduce:

1. Create new game (of any size, 64x64 is enough) with one side of the map edges be water.
2. Build a ship depot on the edge of the map with water.
3. Build one ship, lock the new ship window and spam the "Clone ship" button till you get a lot of ships.
4. Deploy all the ships from the ship depot, all at once.

This bug can be used to grief on servers (via DoS) as it would cause slow clients to freeze and get disconnected from the server.

Affects both YAPF and NPF pathfinders and verified on both Windows and Linux platforms.
This task depends upon

Comment by Marctraider (Marctraider) - Friday, 31 October 2014, 15:04 GMT
Well spamming ships can easily be dealt with the maximum vehicle setting.
Perhaps openttd should get a system that detects whether ships have any orders and let them refuse to leave the dock/depot.

Still your CPU shouldnt overload by boats without orders, thats odd.
Comment by Alberth (Alberth) - Saturday, 01 November 2014, 09:00 GMT
Trying to prevent the issue by measures like not leaving the dock is just plain useless. The counter-example is 1. Build ship. 2. Give an order. 3. Leave dock. 4. Delete order.
Comment by Chu Chin Kuan (moogtrain) - Friday, 20 January 2017, 17:50 GMT
This issue is still reproducible two years later, on OpenTTD 1.6.1.
Comment by Peter Nelson (peter1138) - Thursday, 06 April 2017, 20:05 GMT
This patch make ships skip path finding when a ship has no destination (v->dest_tile == 0) and instead randomly chooses to stay in the same direction or another random direction.
Comment by Peter Nelson (peter1138) - Sunday, 09 April 2017, 14:26 GMT
This then leaves the issue (which is sort of unrelated) that if you then send all your ships to depots it'll start lagging again.

Loading...