-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Describe the bug
The time Message Recorder
s take to execute UpdateState
will regularly spike every 2^n steps for a time that grows at a rate of 2^n e.g., step 16385 may take 4ms, step 32769 may take 8ms, and so on. While the exponentially decreasing frequency of such spikes compensates for their exponential increase in time in non-real-time simulation use, the behavior may pose a problem for real-time simulation use (e.g., hardware-in-the-loop-simulation testing).
This is because Recorder
stores messages using STL vector
which, when it runs out of space, reallocates a new array of double the size, then copies all the existing elements over.
To reproduce
Steps to reproduce the behavior:
- Set up a message and
Recorder
- Run the simulation
Expected behavior
The time Recorder::UpdateState
takes to run should not grow with simulation duration.
Desktop (please complete the following information):
- OS: All
- Version latest
develop
- Python version All
Additional context
This could probably be solved by switching to STL deque
for storage. This would marginally increase average UpdateState
execution time, and general data access time, but unlikely enough noticeable in practice. It would significantly increase the time of anyone taking advantage of vector
storage being contiguous, however, using Python to access to recorded data does NOT do this, and in fact, just makes a copy of all the data anyways.
It could also be solved by introducing a way to force the Recorder
vector
s to reserve
, however this would be more difficult for simulations with indefinite end times, since they would have to reserve
for the theoretical longest run time.
I would favor the deque
solution.