Lagging in a just started game

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Lagging in a just started game

Post by wimpiedimpie »

Problem here.

I created a 4096x4096 world with the cities as big as they possible get by creation of them, with 3 transporting AI's (which, on this moment, each have 3000-5000 vehicles per AI), around ~100 active NewGRF's in the game, and MagicGS gamescript running.
I started the game in 2100, now it is end 2106, so just six years. In that time I build like 10 airports with 40 planes, 10 buses and 30 ships or something like that.
Over the years, I got a few gamescripts failing and also 2 AI's failing, but the game never crashed or even lagged, it was always as fast as it always was.
But then I created a chain of trainstations between 9 cities (each trainstation has 3 tracks) like this: 1->2->3->4->5->6->7->8->9, I did this while pausing the game.
So I bought the trains (three of them) and I gave orders and unpaused the game, but after a few moments the game started immensively lagging (see attachment).
lagging gif.
lagging gif.
lagging.gif (5.35 MiB) Viewed 1300 times


When I reload the savegame, after five seconds, the game starts lagging again. This is very irritating!
It is also very weird, cause before the trains everything worked just alright, and I don't have a bad laptop (game laptop with Ryzen 7 5800H, 32 GB RAM, RTX 3070 Ti and Samsung SSD).

Please help me! Thanks in advance!
Greetings!
skc
Traffic Manager
Traffic Manager
Posts: 177
Joined: 17 Sep 2022 02:02

Re: Lagging in a just started game

Post by skc »

Which OS and version of OpenTTD are you using?

Also, are you able to provide a copy of the savegame file?
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Re: Lagging in a just started game

Post by wimpiedimpie »

OS: Windows 11 Pro version 23H2 x64 (I'm keeping it up to date each day)
I'm using the beta: OpenTTD 14.0-beta3
see attachment below for savegame file
megaprojekt but lagging.sav
(18.24 MiB) Downloaded 16 times
Last edited by wimpiedimpie on 14 Feb 2024 11:45, edited 1 time in total.
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Re: Lagging in a just started game

Post by wimpiedimpie »

I just looked up a earlier version of the same savegame where it yet didn't lag, but after 10 days (in-game), it started lagging too, so it seems to be not the problem with the trains

EDIT:
I did also run a new game without newgrfs but with AI's and also 4096x4096 again and after 100 years it still didn't lag so I think it's because of the NewGRF's
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: Lagging in a just started game

Post by peter1138 »

1) You're running a 4096x4096 map. This is going to be CPU demanding.
2) Your AIs have 2000, 5000, and 5000 road vehicles each. This is going to be CPU demanding.
3) You've set script #opcodes to 100,000, ten times the default of 10,0000. This is going to be CPU demanding.
4) You've loaded 100 NewGRFs, depending on what they do, this is going to be CPU demanding.

I don't think you can class a game with 16,000 vehicles "Just started" really!
He's like, some kind of OpenTTD developer.
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Re: Lagging in a just started game

Post by wimpiedimpie »

peter1138 wrote: 15 Feb 2024 18:46 1) You're running a 4096x4096 map. This is going to be CPU demanding.
2) Your AIs have 2000, 5000, and 5000 road vehicles each. This is going to be CPU demanding.
3) You've set script #opcodes to 100,000, ten times the default of 10,0000. This is going to be CPU demanding.
4) You've loaded 100 NewGRFs, depending on what they do, this is going to be CPU demanding.

I don't think you can class a game with 16,000 vehicles "Just started" really!
Yeah I get it😄, but my CPU never gets above 15% for OpenTTD (I see that in my task manager in windows), so is OpenTTD so inefficient in CPU usage?
And I have a not bad CPU: Ryzen 7 5800H, so that's weird too.
I will check the setting for scripts and AI's, as they perhaps are a bit exaggerated yeah😄
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: Lagging in a just started game

Post by peter1138 »

It's not so much that OpenTTD is inefficient, it is because you've told it to run scripts 10x as much as normal, along with 10x as many road vehicles as normal, AND to top it off the CityLifeAI script (which is not OpenTTD itself) is not very well behaved -- it is trying to run as fast as it can, and you've told the game it can run 10x as long as normal. So it is.
He's like, some kind of OpenTTD developer.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: Lagging in a just started game

Post by peter1138 »

He's like, some kind of OpenTTD developer.
_dp_
Transport Coordinator
Transport Coordinator
Posts: 278
Joined: 18 Dec 2013 12:32

Re: Lagging in a just started game

Post by _dp_ »

wimpiedimpie wrote: 15 Feb 2024 19:36 Yeah I get it😄, but my CPU never gets above 15% for OpenTTD (I see that in my task manager in windows), so is OpenTTD so inefficient in CPU usage?
It may be showing % of all cores, OpenTTD only uses one and with 8 cores 100% load will be close to 15% overall.
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Re: Lagging in a just started game

Post by wimpiedimpie »

It may be showing % of all cores, OpenTTD only uses one and with 8 cores 100% load will be close to 15% overall.
Okay, I guess OpenTTD was indeed using maximum CPU amount...
Can't that be changed in a way that OpenTTD uses all cores?
peter1138 wrote: 15 Feb 2024 19:58 It's not so much that OpenTTD is inefficient, it is because you've told it to run scripts 10x as much as normal, along with 10x as many road vehicles as normal, AND to top it off the CityLifeAI script (which is not OpenTTD itself) is not very well behaved -- it is trying to run as fast as it can, and you've told the game it can run 10x as long as normal. So it is.
Okay, thanks for the info and the link, I now understand more clearly
User avatar
jfs
Tycoon
Tycoon
Posts: 1764
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Lagging in a just started game

Post by jfs »

wimpiedimpie wrote: 15 Feb 2024 22:56 Can't that be changed in a way that OpenTTD uses all cores?
That's an extremely difficult problem because it will involve completely ripping out all of the game logic and rewrite it in a new way where it can run in parallel. I won't go into detail here, but you can find other threads discussing the difficulty of making OpenTTD multi-threaded on the forums.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Lagging in a just started game

Post by ChillCore »

not saying jfs is wrong ...

but someone did do that indeed ... using more cores ... way back
turns out the game was slower .. so yeah ...
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Re: Lagging in a just started game

Post by wimpiedimpie »

ChillCore wrote: 16 Feb 2024 09:15 turns out the game was slower .. so yeah ...
Wait, so you mean that as a result that OpenTTD was made multithreaded, the game was slower then before?! That sounds bad!

Sounds like it can't be done properly/easily...
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Re: Lagging in a just started game

Post by wimpiedimpie »

Other question: can you delete newgrf's from your system? Can you simply delete from where they were downloaded (in file explorer) or does OpenTTD support deleting NewGRF's?
Or at least preventing NewGRF's from being loaded into OpenTTD when you start the game?
Argus
Tycoon
Tycoon
Posts: 1204
Joined: 16 Oct 2018 08:31
Location: Heart of the Highlands. Not Scottish. Czech.

Re: Lagging in a just started game

Post by Argus »

Note that Openttd is built on the core of a game that was created when the modern computer was the IBM 286, if I'm not mistaken. It simply didn't account for multi-core processors, and apparently it's going to be really hard to do without completely rewriting the entire code.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Lagging in a just started game

Post by ChillCore »

wimpiedimpie wrote: 16 Feb 2024 09:26
ChillCore wrote: 16 Feb 2024 09:15 turns out the game was slower .. so yeah ...
Wait, so you mean that as a result that OpenTTD was made multithreaded, the game was slower then before?! That sounds bad!

Sounds like it can't be done properly/easily...
it was indeed ... so yeah ...

do take into account that all is calculatd on the fly and with that the whole map ... not just only what you see ... as opposed to 3d shooters where enemies just sit idle doing f-all untill you get there ... and also that some things that could have been moved to other cores have been ... like saving and things ...
Last edited by ChillCore on 16 Feb 2024 22:50, edited 1 time in total.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Lagging in a just started game

Post by ChillCore »

wimpiedimpie wrote: 16 Feb 2024 09:26 Sounds like it can't be done properly/easily...
show us?

... but yeah not easy

the "waiting for other cores" thinghy made it slower
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
User avatar
kamnet
Moderator
Moderator
Posts: 8589
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Lagging in a just started game

Post by kamnet »

wimpiedimpie wrote: 16 Feb 2024 10:47 Other question: can you delete newgrf's from your system? Can you simply delete from where they were downloaded (in file explorer) or does OpenTTD support deleting NewGRF's?
Or at least preventing NewGRF's from being loaded into OpenTTD when you start the game?
NewGRFs are not loaded when you start OpenTTD, but they are scanned for in order to populate the in-game NewGRF list. If you want to ensure a NewGRF isn't loaded before you start a new game in OpenTTD, make sure it's removed from your list of active NewGRFs. If it's in a scenario file, then you can't remove it and the scenario won't load without it (unless you intentionally make some alterations which can also break stuff, there's another topic here for that).

OpenTTD doesn't support deletion of a NewGRF from within the game. You can remove it from your OS file manager. But if you have a scenario file, save or preset that used it, the in-game content service will automatically download it again.
Argus wrote: 16 Feb 2024 22:28 Note that Openttd is built on the core of a game that was created when the modern computer was the IBM 286, if I'm not mistaken.
The 286 CPU was early 80s. The minimum system requirements for TTD was an Intel 486 CPU, 4 MB of RAM running MS-DOS 6 or newer.
wimpiedimpie
Engineer
Engineer
Posts: 11
Joined: 13 Feb 2024 21:41

Re: Lagging in a just started game

Post by wimpiedimpie »

Thank you all for the information
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Lagging in a just started game

Post by ChillCore »

wimpiedimpie wrote: 17 Feb 2024 00:18 Thank you all for the information
you are welcome ....
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 24 guests