Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage for ships with empty orders #6145

Closed
DorpsGek opened this issue Oct 20, 2014 · 9 comments
Closed

High CPU usage for ships with empty orders #6145

DorpsGek opened this issue Oct 20, 2014 · 9 comments
Labels
bug Something isn't working flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) good first issue Good for newcomers patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

moogtrain opened the ticket and wrote:

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.

Reported version: 1.4.3
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6145
@DorpsGek
Copy link
Member Author

Marctraider wrote:

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.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6145#comment13606

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 1, 2014

Alberth wrote:

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.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6145#comment13607

@DorpsGek
Copy link
Member Author

moogtrain wrote:

This issue is still reproducible two years later, on OpenTTD 1.6.1.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6145#comment14351

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 6, 2017

peter1138 wrote:

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.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6145#comment14425

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 9, 2017

peter1138 wrote:

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.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6145#comment14430

@DorpsGek
Copy link
Member Author

andythenorth wrote:

[removed comment after discussion with peter1138 that this is actually a bug, and not just about griefing]


This comment was imported from FlySpray: https://bugs.openttd.org/task/6145#comment14666

@DorpsGek
Copy link
Member Author

andythenorth wrote:

Confirmed Peter's patch does the job. Tested single player, ffwd. Without patch: game chugs in FFWD. With patch: smooth enough.

Video is worth a watch eh? (Loading pre-patch savegame into patched ottd).

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6145#comment14668

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) Vehicles labels Apr 7, 2018
@TrueBrain TrueBrain added good first issue Good for newcomers patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay bug Something isn't working and removed bug from FlySpray labels Apr 10, 2018
nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Nov 1, 2018
@andythenorth
Copy link
Contributor

Thanks for this. There's been no activity on this for some time, and as it stands, it doesn't look likely that it will go any further. Since OpenTTD moved to GitHub, we use pull requests rather than patches, as they are a much more productive workflow.

I'm planning to close this soon (in 7 days), as we try to keep the issue count low for OpenTTD, it helps us focus on things that are important and fun.

If you would like to continue with this patch, the best way would be to move the patch to your own GitHub fork, update it for the current OpenTTD master, and then create a pull request. For more information, please see our CONTRIBUTING.md.

We are also happy to discuss directly on the issue, or in #openttd irc, including help to get this into a pull request. Thanks for your contribution!

@andythenorth andythenorth added the stale Stale issues label Jan 5, 2019
nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Jan 5, 2019
@andythenorth andythenorth removed the stale Stale issues label Jan 7, 2019
@LordAro
Copy link
Member

LordAro commented Jan 14, 2019

Fixed in #6784

@LordAro LordAro closed this as completed Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) good first issue Good for newcomers patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

5 participants