Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading Track metadata becomes costly for Tracks with long state histories #118

Closed
sglvladi opened this issue Jun 28, 2019 · 1 comment
Closed

Comments

@sglvladi
Copy link
Collaborator

Following experimentation with some large scale AIS datasets and it has been observed that continuously reading the Track metadata becomes a costly operation, especially as the state history of a Track grows. This due to the fact that the getter method has to iterate over all the states to yield the result as it can be seen here.

A potential fix can be applied by replacing the above lines as follows:

@property
def metadata(self):
...
    for state in reversed(self.states):
        if isinstance(state, Update)\
           and state.hypothesis.measurement.metadata is not None:
            metadata.update(state.hypothesis.measurement.metadata)
            break
...

Here is an example profiler output running the same code with the old and new versions:

Old

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
4789021  184.180    0.000 1897.829    0.000 ...\stonesoup\stonesoup\types\track.py:31(metadata)

New

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
4789021  103.760    0.000  399.821    0.000 ...\stonesoup\stonesoup\types\track.py:31(metadata)

However, by doing so, only the metadata fields of the latest detection are returned, which may not be desireable (e.g. in cases where the metadata fields vary between detections).

Seeing as metadata is becoming quite heavily used in StoneSoup, it may be worth having a different approach to storing/updating the Track metadata.

@sglvladi
Copy link
Collaborator Author

sglvladi commented Apr 4, 2020

This has been fixed in #121

@sglvladi sglvladi closed this as completed Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant