Repository navigation
Conversation
Prepares for adding a set type alongside the vector types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A set of pointers stored in a vector sorted by address. Erased elements are marked as removed and skipped when iterating, then compacted away once they outnumber the remaining elements, so erasing is amortized O(1) after an O(log n) lookup instead of shifting the rest of the vector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removing a subgraph from the graph used std::remove over the sorted vector of subgraphs, which is O(n), so invalidating n subgraphs together (e.g. tearing down a graph) was O(n^2). Erasing from IAG::set is amortized O(1) after a binary search, and iteration order is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
No longer needed. The performance impact was only observable at about 300,000 subgraphs, which were reduced downstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tearing down a graph with many subgraphs took minutes. Every removal called Graph::remove_subgraph, which ran std::remove over the sorted _subgraphs vector. That is O(n) per subgraph, so invalidating n subgraphs together was O(n²). This hits graph.invalidate(), withoutSubgraphInvalidation, and invalidations deferred inside Subgraph.forEach.
_subgraphs is now an IAG::set: a vector sorted by address that marks erased elements as removed and compacts them once they outnumber the live ones. Removing a subgraph is a binary search plus amortized O(1) work.