astutils.cpp: optimized visitAstNodesGeneric() a bit #3716
Merged
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.
I tested this with
cli/filelister.cpp. I wanted to test it with more files but with all the recent performance regressions it's agonizing slow while running invalgrind.The initial Ir count was
353,306,619.Reducing the
std::stackoperations by not addingnullptrentries reduced it to334,276,673even though the checks added some overhead.Switching the backend of the
std::stackfromstd::dequetostd::vectorreduced it to293,371,232. The main problem is that the construction of astd::dequeis much more expensive. The destruction cost stays the same.So in total this saves us about 12% of the Ir count.
The main issue here still remains the creation and destruction of
std::stackwhich still amounts to more than 22% of the total Ir count. So it's the same issue we are seeing with short-living smallstd::vectoras related to in #3432. It is also still the single most expensive function we call.