18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 07:07:05 +01:00
Files
maszyna/physics
jerrrrycho 0c4aa1fe30 perf(physics): the hose exchange goes through the vehicles of each train only
exchange_through_hoses() takes the air exchange through the brake and the main reservoir hoses train
by train, each in its own number of sub-steps (up to 10). For every sub-step of every train it went
through the whole list of vehicles, all of the scenery's in update_brake_pipes(), and looked into each
one's pipe to tell whether it belongs to that train: trains x sub-steps x vehicles reads of vehicles
scattered in memory, twice a step (both pipes). In Tomaszewo, with 129 trainsets, this alone was 38.6%
of the main thread.

The vehicles of each train are now put in a list once per call (a counting sort of the train numbers
hose_trains() gives, keeping the order of the list within a train), and a sub-step goes through its
train's list. The membership is the one the loop tested (a vehicle is in a train when its pipe stepped,
which nothing changes during the exchange), the trains, the sub-steps and the vehicles within a train
come in the same order, so every Flow()/Act() happens in the same order with the same values.

Tomaszewo (raj40821) 600 s in --test, seed 12345: sim 206.7 s against 275.3 s the step before (one
run each, same session, -25%); wall 365.8 s against 447.5 s (the load, ~150-165 s, is unchanged). In an
earlier series 3 runs gave 187.3 s median (183.0-195.6) against 265.6 s. The 14 physics logs and the
event log are byte-identical, unit tests 1205/1205 with exact golden traces.
2026-11-30 06:50:29 +01:00
..