Transport Fever 2

Transport Fever 2

LineManager
This topic has been locked
MaxCheng95 10 Dec, 2022 @ 9:51pm
LM overwhalmed by the map?
Hello. Recently I've noticed that the LM itself isn't working properly with no vehicles being added or removed automatically as it should've been. Not even with syntaxes added to line names would the manager work. I just checked the console in game and noticed it's been looping the following debug message over and over since loading up the game:

[LineManager][13:43:50][DEBUG] linemanager: regularUpdate() starting
[LineManager][13:43:50][DEBUG] linemanager: regularUpdate() finished
[LineManager][13:43:50][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][13:43:50][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][13:43:50][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][13:43:50][DEBUG] sampling: CPU time used: 0.0010000000002037

Does this mean the mod is simply overwhalmed by the amount of lines and vehicles I have on the map? If so, is there anything I can do on my end to fix this?
< >
Showing 1-15 of 15 comments
CARTOK  [developer] 10 Dec, 2022 @ 11:44pm 
No, that should just be the rate limiting that ensures each sampling run completes well within the tick time limit (5 ticks per second, so max 200ms can be used in total for all processing including all mods etc.). If you have a large map, the sampled data could be processed over an extended period to ensure the game runs smoothly. If you have vehicle numbers changing on lines, then the sampling is working. Do you perhaps have a complete log extract you can post that captures from start to end of a _full_ sample processing? (Not only a single tick as per the extract above, but the full time period - could be 20-30-40 seconds or more from start to finish depending on the size of your game).
CARTOK  [developer] 10 Dec, 2022 @ 11:47pm 
For my reference; how big is your game? (Lines, vehicles, entities transported etc.)
MaxCheng95 11 Dec, 2022 @ 12:07am 
In my current game I have 538 lines served by 1762 vehicles. Transported 1.75mil passengers and 4.25mil cargo. Of those about 380 lines (mostly road and tram) served by 1400 vehicles are controlled by LM.
MaxCheng95 11 Dec, 2022 @ 12:11am 
As for the log, do you mean the console log? I have the stdout.txt uploaded here https://drive.google.com/file/d/1pUQfV40OBBHz_sxwRQLic7JfvCCxdrlf/view?usp=sharing if you need to see the full debug script.
MaxCheng95 11 Dec, 2022 @ 12:20am 
Also the processing never seems to have completed in the first place. Since the start of a game load up it begins with one "============ Sampling ============" then the endless loop of what I put on the first post, never reaches the stage of actual updating
CARTOK  [developer] 11 Dec, 2022 @ 12:45am 
Ok, that is a massive game, bigger than the largest I've tested. It looks like it simply takes so long to process all the entities that it simply doesn't complete quick enough for you to notice a change. From what the log indicates, the processing seems to work as intended though. If you have a decent computer (assuming it is the case given your massive game), you can try upping the processing limits to speed up the sampling - the default settings are intentionally "moderate" to ensure they will work well for most people.

Open the file: sampling.lua, and look for the following lines:
local MAX_LINES_TO_PROCESS_PER_RUN = 20 -- Maximum lines to process per run
local MAX_VEHICLES_TO_PROCESS_PER_RUN = 50 -- Maximum vehicles to process per run
local MAX_ENTITIES_TO_PROCESS_PER_RUN = 300 -- Maximum entities to process per run

Change MAX_ENTITIES_TO_PROCESS_PER_RUN to 1000, if that works well (no crashes or debug CPU time starting to get close to 0.2, then increase it as far as you want. Maybe even 5000 will work for you?

With that setting upped, the processing will be sped up accordingly (at risk of exceeding the tick time, you'll have to tweak it as per your system/game). I.e. changing from 300 to 600 will double the processing speed (in simplistic terms).

Give it a try and let me know how it works. Any more logs you can share are appreciated!
CARTOK  [developer] 11 Dec, 2022 @ 12:52am 
Another one; if you can share the "*.sav.lua" file from your game (from the same time/game you share the log), that would be helpful as well as the stored data from LineManager can be read in plain-text in that file. If your save file is "Hoenn.sav", then there should be a "Hoenn.sav.lua" file in the same folder.

Sample extract from my own game:
[111364] = {
action = "",
capacity = 162,
capacity_per_vehicle = 162,
carrier = "RAIL",
demand = 0,
depot_id = 94102,
frequency = 452.7,
has_problem = false,
last_action = "",
managed = true,
name = "Line 4",
occupancy = 0,
occupancy_peak = 0,
parameters = {
{
max = 1,
min = 0,
name = "level",
value = 0,
},
},
rate = 261.4,
rule = "P",
rule_manual = false,
samples = 51,
stops = 4,
stops_with_waiting = 0,
transported_last_month = 0,
transported_last_year = 0,
type = "PASSENGER",
usage = 0,
vehicles = 1,
waiting = 0,
waiting_peak = 0,
waiting_peak_clamped = 0,
},
CARTOK  [developer] 11 Dec, 2022 @ 1:00am 
Hmm, a closer look seems to indicate that the update/tick cycles possibly are extremely slow in your game. It only runs every 4-12 seconds or so, whereas it should be running several times per second. Here's from a quick test scenario I have, note the frequency of the processing (several times per second):
[LineManager][12:55:24][INFO] ============ Sampling ============
[LineManager][12:55:24][DEBUG] sampling: start()
[LineManager][12:55:24][DEBUG] sampling: restart()
[LineManager][12:55:24][DEBUG] linemanager: regularUpdate() finished
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:24][DEBUG] sampling: prepareInitialData() starting
[LineManager][12:55:24][DEBUG] sampling: prepareInitialData() completed successfully
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0030000000000001
[LineManager][12:55:24][DEBUG] sampling: prepareLineData() starting
[LineManager][12:55:24][DEBUG] sampling: prepareLineData() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: prepareLineData() processed 17 lines and 52 vehicles
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:24][DEBUG] sampling: prepareLineData() starting
[LineManager][12:55:24][DEBUG] sampling: prepareLineData() processed 16 lines and 34 vehicles
[LineManager][12:55:24][DEBUG] sampling: prepareLineData() completed successfully
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0030000000000001
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 5 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.00099999999999056
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 2 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 4 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 4 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 2 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.00099999999999056
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 2 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 2 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0020000000000095
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 1 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.00099999999999056
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0019999999999953
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:24][DEBUG] sampling: sampleWaitingCargo() processed 0 lines and 300 new items
[LineManager][12:55:24][DEBUG] sampling: CPU time used: 0.00099999999999056
[Auto-Rename] Renamed 0 vehicles across 33 lines in 0 ms.
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() processed 1 lines and 300 new items
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0.0020000000000095
[LineManager][12:55:25][DEBUG] linemanager: regularUpdate() starting
[LineManager][12:55:25][DEBUG] linemanager: regularUpdate() finished
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() processed 4 lines and 300 new items
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() processing limit reached, stopping
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() processed 4 lines and 300 new items
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() starting
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() processed 2 lines and 98 new items
[LineManager][12:55:25][DEBUG] sampling: sampleWaitingCargo() completed successfully
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:25][DEBUG] sampling: mergeLineData() starting
[LineManager][12:55:25][DEBUG] sampling: mergeLineData() processing limit reached, stopping
[LineManager][12:55:25][DEBUG] sampling: mergeLineData() processed 20 lines
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:25][DEBUG] sampling: mergeLineData() starting
[LineManager][12:55:25][DEBUG] sampling: mergeLineData() processed 13 lines
[LineManager][12:55:25][DEBUG] sampling: mergeLineData() completed successfully
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0
[LineManager][12:55:25][DEBUG] sampling: applyRules() starting
[LineManager][12:55:25][DEBUG] sampling: applyRules() processed 20 lines
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:25][DEBUG] sampling: applyRules() starting
[LineManager][12:55:25][DEBUG] sampling: applyRules() processed 13 lines
[LineManager][12:55:25][DEBUG] sampling: applyRules() completed successfully
[LineManager][12:55:25][DEBUG] sampling: CPU time used: 0.0010000000000048
[LineManager][12:55:26][DEBUG] linemanager: regularUpdate() starting
[LineManager][12:55:26][DEBUG] sampling: stop()
[LineManager][12:55:26][INFO] ============ Updating ============
[LineManager][12:55:26][DEBUG] linemanager: updateLines() starting
[LineManager][12:55:26][DEBUG] linemanager: removeVehicleFromLine(119819) starting
[LineManager][12:55:26][DEBUG] sampling: getEmptyVehicles() started
[LineManager][12:55:26][DEBUG] sampling: getEmptyVehicles() found 0 empty vehicles
[LineManager][12:55:26][DEBUG] helper: findDepotAndStop(line_id: 119819 vehicle_id:79790) starting
[LineManager][12:55:26][DEBUG] helper: findDepotAndStop(...) finished. depot_id=119821 stop_id=1
[LineManager][12:55:26][INFO] -1 vehicle: Cockermouth CW
[LineManager][12:55:26][INFO] PASSENGER - ROAD - Rule: P (0) - AUTOMATIC (Samples: 85)
[LineManager][12:55:26][INFO] Usage: 39% Rate: 126 WaitingPeak: 11 CapPerVeh: 17 Vehicles: 2
[LineManager][12:55:26][DEBUG] vehicle_id: 79790 line_id: 119819
[LineManager][12:55:26][DEBUG] linemanager: removeVehicleFromLine(119819) finished. success=true
[LineManager][12:55:26][DEBUG] linemanager: addVehicleToLine(81547) starting
[LineManager][12:55:26][INFO] +1 vehicle: St Ives CW
[LineManager][12:55:26][INFO] PASSENGER - ROAD - Rule: P (0) - AUTOMATIC (Samples: 14)
[LineManager][12:55:26][INFO] Usage: 51% Rate: 196 WaitingPeak: 23 CapPerVeh: 17 Vehicles: 4
[LineManager][12:55:26][DEBUG] vehicle_id: 79790 line_id: 81547 depot_id: 123122
[LineManager][12:55:26][DEBUG] linemanager: session_cachedDepotHit=2 session_cachedDepotMiss=0
[LineManager][12:55:26][DEBUG] linemanager: addVehicleToLine(81547) finished. success=true
[LineManager][12:55:26][INFO] ==> SUMMARY: 33 lines and 86 vehicles managed (0 lines not managed)
CARTOK  [developer] 11 Dec, 2022 @ 1:02am 
And here's an extract from your log-file (note the 9 second gap between the consecutive runs - that will slow the overall updates down to a crawl and will likely never complete):
[LineManager][13:10:38][DEBUG] linemanager: regularUpdate() starting
[LineManager][13:10:38][DEBUG] linemanager: regularUpdate() finished
[LineManager][13:10:38][DEBUG] sampling: prepareLineData() starting
[LineManager][13:10:38][DEBUG] sampling: prepareLineData() processing limit reached, stopping
[LineManager][13:10:38][DEBUG] sampling: prepareLineData() processed 9 lines and 50 vehicles
[LineManager][13:10:38][DEBUG] sampling: CPU time used: 0.011000000000195
[LineManager][13:10:47][DEBUG] linemanager: regularUpdate() starting
[LineManager][13:10:47][DEBUG] linemanager: regularUpdate() finished
[LineManager][13:10:47][DEBUG] sampling: prepareLineData() starting
[LineManager][13:10:47][DEBUG] sampling: prepareLineData() processing limit reached, stopping
[LineManager][13:10:47][DEBUG] sampling: prepareLineData() processed 10 lines and 50 vehicles
[LineManager][13:10:47][DEBUG] sampling: CPU time used: 0.010999999999967
CARTOK  [developer] 11 Dec, 2022 @ 1:02am 
Do you have a mod that possibly interferes with something here?
MaxCheng95 11 Dec, 2022 @ 1:29am 
Not that I could think of. The only script mods similar to this are global update, timetable, transit orient development, and performance tuning mods.

Here's the .sav.lua file you requested https://drive.google.com/file/d/1sQ-yKA7OD9K5UpPiocE12Ml4RG9jJ14n/view?usp=sharing

And I'm gonna try to up the processing limit and see what happens, thanks fo far!
CARTOK  [developer] 11 Dec, 2022 @ 2:46am 
Thank you, let me know how it goes!

Looking at the sav.lua-file, it looks like it is working, I notice "action" being indicated, as well as "last_action" - and the data seem aligned with what would trigger those actions. Maybe just the log files not keeping up, or something? Hard to say in isolation, maybe just let it run for a while and double-check if it is actually working? Note that changes are gradual over time, one vehicle at a time - there are no complete overhauls of vehicle allocation just continuous tuning of the numbers based on how the line is performing.

Sample extract from the provided sav.lua-file:
[261084] = {
action = "ADD",
capacity = 168,
capacity_per_vehicle = 56,
carrier = "ROAD",
demand = 555.6,
depot_id = 609087,
depot_stop_id = 14,
frequency = 898.3,
has_problem = false,
last_action = "ADD",
managed = true,
name = "MetroBus (11) <Aspertia>",
occupancy = 18,
occupancy_peak = 10,
parameters = {
{
max = 1,
min = 0,
name = "level",
value = 0,
},
},
rate = 52.4,
rule = "P",
rule_manual = false,
samples = 0,
stops = 22,
stops_with_waiting = 18.76,
transported_last_month = 54,
transported_last_year = 289,
type = "PASSENGER",
usage = 45.6,
vehicles = 4,
waiting = 413.4,
waiting_peak = 89.7,
waiting_peak_clamped = 53.9,
},
MaxCheng95 11 Dec, 2022 @ 7:33am 
Turns out the problem came down to the large amount of cargo that was never resolved during sampling. I ended up setting the sampling to process 200k entities in one run and it worked, cleared the sampling in 3 runs or so. Also upped the amount of lines and vehicles too. Thanks a lot for the help!
CARTOK  [developer] 11 Dec, 2022 @ 7:58am 
Good to hear! Note that if you set the number of entities per run too high you might get random crashes if the processing exceeds the tick time (~200ms). The DEBUG CPU time should give an idea how close you are, although I'm admittedly not 100% certain that CPU time is the best measurement.

There was something wonky about the big gaps between processing runs I noted in the log you provided (4-12 seconds noted in the log, whereas it should happen several times per second). Not sure what that was, maybe an artifact of something else... Hmm.

Anyhow, as long as it works, happy days! Let me know if you face any issues!
CARTOK  [developer] 20 Dec, 2022 @ 8:22am 
I gather this has been resolved, so I will lock this thread. Please open a new one if there's any further observations. Have fun gaming!
< >
Showing 1-15 of 15 comments
Per page: 1530 50