Perf: replace std::unordered_map with boost::unordered_flat_map/set#16849
Open
sbillig wants to merge 3 commits into
Open
Perf: replace std::unordered_map with boost::unordered_flat_map/set#16849sbillig wants to merge 3 commits into
sbillig wants to merge 3 commits into
Conversation
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.
Description
Replaces all uses of std::unordered_map/set with boost unordered_flat_map/set, and replaces std::unordered_multimap with boost::unordered_multimap. This provides a nice speedup on the purplebench suite locally (though results were noisy on my laptop so take this with a grain of salt). I'd appreciate a benchmark run on the dedicated machine.
The only real risk here is flat_map's reference (in)stability across inserts. I don't see any cases where this is currently a problem. There may be some instances where unordered_map is better than flat_map, eg where the value type is large, or in cases with a lot of updates. I ran the BalancerV3Vault benchmark case, flat_map vs unordered_map for these instances locally and flat_map was never worse, but this could use more testing:
(these are cases where the value is non-trivial (eg std::set), and/or there's potentially a lot of mutation)
CommonSubexpressionEliminator.h:172
ControlFlowSideEffectsCollector.h:130
CommonSubexpressionEliminator.h:66
DataFlowAnalyzer.h:184
SSACFGBuilder.h:159
I'm sure using flat_map in more places was on everyone's radar; thought it was worthwhile running this experiment. Happy to roll back individual uses or whatever.
Checklist
AI Disclosure
This is just a find-and-replace PR, and AI did it. AI also ran benchmarks for me.