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

Performance/intervalmap #1371

Merged
merged 6 commits into from
Mar 29, 2024
Merged

Performance/intervalmap #1371

merged 6 commits into from
Mar 29, 2024

Conversation

bradNASA
Copy link
Contributor

@bradNASA bradNASA commented Mar 21, 2024

  • Tickets addressed: none, afaik
  • Review: By file ?
  • Merge strategy: Merge (no squash)

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.

@bradNASA bradNASA requested a review from a team as a code owner March 21, 2024 00:17
@bradNASA bradNASA requested a review from JoelCourtney March 21, 2024 00:18
@bradNASA
Copy link
Contributor Author

@mattdailis Any reason we shouldn't merge this?

Copy link
Contributor

@JoelCourtney JoelCourtney left a 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. 👍

@bradNASA
Copy link
Contributor Author

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.

@dandelany
Copy link
Collaborator

Thanks @bradNASA , merging!

@dandelany dandelany merged commit e57d756 into develop Mar 29, 2024
6 checks passed
@dandelany dandelany deleted the performance/intervalmap branch March 29, 2024 23:47
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

Successfully merging this pull request may close these issues.

4 participants