-
Notifications
You must be signed in to change notification settings - Fork 22
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
Performance/intervalmap #1371
Performance/intervalmap #1371
Conversation
merlin-sdk/src/main/java/gov/nasa/jpl/aerie/merlin/protocol/types/SerializedValue.java
Show resolved
Hide resolved
constraints/src/main/java/gov/nasa/jpl/aerie/constraints/time/IntervalAlgebra.java
Outdated
Show resolved
Hide resolved
@mattdailis Any reason we shouldn't merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at every change to IntervalMap in detail, but I do know that Pranav and I tested the bejeezus out of that class back in the day. It sounds theoretically sound and the tests pass. 👍
Yeah, I was impressed with the detail of the test suite. |
afefed5
to
c8faac5
Compare
c8faac5
to
1cd8714
Compare
Thanks @bradNASA , merging! |
Description
IntervalMap changed to use TreeSet instead of ArrayList for Segments to speed up set(), which is used to construct an IntervalMap from a list of Segments. Some SPHEREx scheduling code for merging SimulationResults is very slow because set() makes IntervalMap construction O(n^2). The use of TreeSet makes that O(n log n). I am not sure what other code may benefit from this.
Joel Courtney pointed out that the use of a list is more efficient in some cases, for example, for appending non-overlapping Segments. He thought it might make sense to keep the list and use a tree in some cases. There may be some better data structure that takes advantage of both, like an ordered list with binary search operations; maybe a skip list would, too.
There's a shortcut checking whether the input segments meet invariant conditions in order to ingest Segments without using set(), which handles overlapping.
There are changes to IntervalAlgebra for faster low-level interval queries.
Verification
Unit tests pass seemingly faster (maybe 3.25 instead of 3.75 minutess), but variance is high. I still need to verify it solves the problem in the SPHEREx model.
Documentation
None, afaik
Future work
Interval code elsewhere in Aerie may also need updating like this.