Page 1 of 1

Lagging in a just started game

Posted: 13 Feb 2024 22:05
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 2826 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!

Re: Lagging in a just started game

Posted: 14 Feb 2024 11:08
by skc
Which OS and version of OpenTTD are you using?

Also, are you able to provide a copy of the savegame file?

Re: Lagging in a just started game

Posted: 14 Feb 2024 11:43
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 105 times

Re: Lagging in a just started game

Posted: 14 Feb 2024 14:14
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

Re: Lagging in a just started game

Posted: 15 Feb 2024 18:46
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!

Re: Lagging in a just started game

Posted: 15 Feb 2024 19:36
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😄

Re: Lagging in a just started game

Posted: 15 Feb 2024 19:58
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.

Re: Lagging in a just started game

Posted: 15 Feb 2024 20:05
by peter1138

Re: Lagging in a just started game

Posted: 15 Feb 2024 20:29
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.

Re: Lagging in a just started game

Posted: 15 Feb 2024 22:56
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

Re: Lagging in a just started game

Posted: 16 Feb 2024 08:04
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.

Re: Lagging in a just started game

Posted: 16 Feb 2024 09:15
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 ...

Re: Lagging in a just started game

Posted: 16 Feb 2024 09:26
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...

Re: Lagging in a just started game

Posted: 16 Feb 2024 10:47
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?

Re: Lagging in a just started game

Posted: 16 Feb 2024 22:28
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.

Re: Lagging in a just started game

Posted: 16 Feb 2024 22:44
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 ...

Re: Lagging in a just started game

Posted: 16 Feb 2024 22:45
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

Re: Lagging in a just started game

Posted: 17 Feb 2024 00:10
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.

Re: Lagging in a just started game

Posted: 17 Feb 2024 00:18
by wimpiedimpie
Thank you all for the information

Re: Lagging in a just started game

Posted: 17 Feb 2024 01:17
by ChillCore
wimpiedimpie wrote: 17 Feb 2024 00:18 Thank you all for the information
you are welcome ....