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

Convert the traverse method of the problem space of the remove_finished_goals from BFS into a DFS (stack->queue). #1853

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Dec 11, 2024

Convert the traverse method of the problem space of the remove_finished_goals from BFS into a DFS (stack->queue).

Profile shows that the majority of the CPU time is spent in construction and destruction of a tree (std::set), which a bigger chunk is coming from mostly caused by copy construction and destruction followed after that.

The problem space that this function is navigating is big enough that the data structure used cannot be simplified (four sets to track the state of traversal), but if we change the iteration from a BFS into a DFS, we get the benefit to avoid the copy, but rather being able to keep the increment and decrement diff of each iteration and only remember those, which will help avoid copying massive data structures which is super costly.

I've tested out whether converting containers into an unordered_set helps, but I only saw some differences that could be considered as a noise, so I'd rather not have those changes.

This change doesn't affect any existing tests.

@copybara-service copybara-service bot force-pushed the cl/704664031 branch 4 times, most recently from 1c0d9b6 to 2cbb725 Compare December 18, 2024 11:40
…ed_goals from BFS into a DFS (stack->queue).

 Profile shows that the majority of the CPU time is spent in construction  and destruction of a tree (std::set), which a bigger chunk is coming from mostly caused by copy construction and destruction followed after that.

 The problem space that this function is navigating is big enough that the data structure used cannot be simplified (four sets to track the state of traversal), but if we change the iteration from a BFS into a DFS, we get the benefit to avoid the copy, but rather being able to keep the increment and decrement diff of each iteration and only remember those, which will help avoid copying massive data structures which is super costly.

I've tested out whether converting containers into an unordered_set helps, but I only saw some differences that could be considered as a noise, so I'd rather not have those changes.

This change doesn't affect any existing tests.

PiperOrigin-RevId: 707493506
@copybara-service copybara-service bot merged commit 9c6c21b into main Dec 18, 2024
@copybara-service copybara-service bot deleted the cl/704664031 branch December 18, 2024 12:13
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.

1 participant