-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Replace dominators algorithm with simple Lengauer-Tarjan #85013
Merged
Merged
Commits on Dec 6, 2021
-
Implement the simple Lengauer-Tarjan algorithm
This replaces the previous implementation with the simple variant of Lengauer-Tarjan, which performs better in the general case. Performance on the keccak benchmark is about equivalent between the two, but we don't see regressions (and indeed see improvements) on other benchmarks, even on a partially optimized implementation. The implementation here follows that of the pseudocode in "Linear-Time Algorithms for Dominators and Related Problems" thesis by Loukas Georgiadis. The next few commits will optimize the implementation as suggested in the thesis. Several related works are cited in the comments within the implementation, as well. Implement the simple Lengauer-Tarjan algorithm This replaces the previous implementation (from rust-lang#34169), which has not been optimized since, with the simple variant of Lengauer-Tarjan which performs better in the general case. A previous attempt -- not kept in commit history -- attempted a replacement with a bitset-based implementation, but this led to regressions on perf.rust-lang.org benchmarks and equivalent wins for the keccak benchmark, so was rejected. The implementation here follows that of the pseudocode in "Linear-Time Algorithms for Dominators and Related Problems" thesis by Loukas Georgiadis. The next few commits will optimize the implementation as suggested in the thesis. Several related works are cited in the comments within the implementation, as well. On the keccak benchmark, we were previously spending 15% of our cycles computing the NCA / intersect function; this function is quite expensive, especially on modern CPUs, as it chases pointers on every iteration in a tight loop. With this commit, we spend ~0.05% of our time in dominator computation.
Configuration menu - View commit details
-
Copy full SHA for e8d7248 - Browse repository at this point
Copy the full SHA e8d7248View commit details -
Optimization: Merge parent and ancestor arrays
As the paper indicates, the unprocessed vertices in the DFS tree and processed vertices are disjoint, and we can use them in the same space, tracking only the index of the split.
Configuration menu - View commit details
-
Copy full SHA for c82fe0e - Browse repository at this point
Copy the full SHA c82fe0eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7379d24 - Browse repository at this point
Copy the full SHA 7379d24View commit details -
Configuration menu - View commit details
-
Copy full SHA for 92186cb - Browse repository at this point
Copy the full SHA 92186cbView commit details -
Use preorder indices for data structures
This largely avoids remapping from and to the 'real' indices, with the exception of predecessor lookup and the final merge back, and is conceptually better.
Configuration menu - View commit details
-
Copy full SHA for 7d12767 - Browse repository at this point
Copy the full SHA 7d12767View commit details -
This integrates the preorder and postorder traversals into one.
Configuration menu - View commit details
-
Copy full SHA for 8991002 - Browse repository at this point
Copy the full SHA 8991002View commit details -
Configuration menu - View commit details
-
Copy full SHA for 345ada0 - Browse repository at this point
Copy the full SHA 345ada0View commit details -
Configuration menu - View commit details
-
Copy full SHA for cc63ec3 - Browse repository at this point
Copy the full SHA cc63ec3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2b63059 - Browse repository at this point
Copy the full SHA 2b63059View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3187480 - Browse repository at this point
Copy the full SHA 3187480View commit details
Commits on Dec 7, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 15483cc - Browse repository at this point
Copy the full SHA 15483ccView commit details
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.