feat: reduce memory consumption of cycles detection #731
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.
What changes were proposed in this pull request?
Before sending any messages with current sequences, we are filtering out all of them, where the starting vertex of the sequence is grater than the destination vertex of the edge.
Explanation.
At the moment, algorithm finds all of the cycles [1, 2, 3], [2, 3, 1] and [3, 1, 2]. Because of that it creates a huge memory load on iterations as well as on the result. Because we are talking about cycles, it is very easy to return only [1, 2, 3] by checking on each iteration, that the first vertex of the current path is the smallest among all of the vertices. To reduce shuffles, I added a check before sending a message (with list of current paths) that starting vertices of each path are less (by ID) than the destination. Based on this check, not passed it paths are filtered out.
It reduce the memory consumption on both iterations (less stored sequences, more lightweight messages, etc.), reduce the weight of the returned dataframe and does not require from users to deduplicate cycles manually.
Why are the changes needed?
Close #730
P.S. To avoid merge-conflicts, I will update docs as part of the #725