[2.1] performance of TrainManager#request_train_path

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
hgschmie
Fast Inserter
Fast Inserter
Posts: 246
Joined: Tue Feb 06, 2024 5:18 am
Contact:

[2.1] performance of TrainManager#request_train_path

Post by hgschmie »

Is there any information available on how request_train_path performs?

I have some use cases where I am trying to route large(ish) numbers of trains to a station. Do a lot of starts or a lot of goals affect the performance; if those were constant, does the TrainPathRequestType affect it? Is there an upper limit on how long this call may take?

Basically, I try to get a handle on an "upper bound" of that operation. Whether it could end up taking seconds or more to compute pathes.

Grateful for any information.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4947
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.1] performance of TrainManager#request_train_path

Post by boskid »

Upper bound is proportional to how many rail segments (sections of rails not interrupted by signals, train stops, merges or splits) are reachable from the starting positions and this upper bound is reached each time trains pathfinder fails due to no path. Depending on request type some requests may stop early when the result is found.
Post Reply

Return to “Modding discussion”