To eliminate querying the interval tree many many times while iterating over the lanes, we cache the current end of segment. This is a good speed up since this is only updated once or twice. However it creates a data dependency: The cars at the beginning MUST be processed before the cars at the end of the lane. This does not bode well for any flavor of parallelism. The update/lane change is the most expensive part of the simulation (outside of logging)
Since there are no overlaps in any of the lanes, the real gains of the interval tree aren't that great. I reckon it is possible for the LaneInfo structure to hold sets of pairs, which would be faster than the interval tree to query.
To eliminate querying the interval tree many many times while iterating over the lanes, we cache the current end of segment. This is a good speed up since this is only updated once or twice. However it creates a data dependency: The cars at the beginning MUST be processed before the cars at the end of the lane. This does not bode well for any flavor of parallelism. The update/lane change is the most expensive part of the simulation (outside of logging)
Since there are no overlaps in any of the lanes, the real gains of the interval tree aren't that great. I reckon it is possible for the LaneInfo structure to hold sets of pairs, which would be faster than the interval tree to query.