Skip to content

Message Recorder has processing time spikes that grow with simulation duration #788

@sassy-asjp

Description

@sassy-asjp

Describe the bug
The time Message Recorders 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:

  1. Set up a message and Recorder
  2. 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 vectors 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions