astutils.cpp: optimized visitAstNodesGeneric() a bit#3716
Merged
danmar merged 1 commit intocppcheck-opensource:mainfrom Jan 17, 2022
Merged
astutils.cpp: optimized visitAstNodesGeneric() a bit#3716danmar merged 1 commit intocppcheck-opensource:mainfrom
danmar merged 1 commit intocppcheck-opensource:mainfrom
Conversation
Collaborator
Author
|
These numbers apply to Clang 13 - with GCC 11 this speed-up in switching the container does not happen. I will try to dig into it and report it upstream. I have some further optimization which improves the speed for GCC to match current Clang as well as improving Clang. |
Collaborator
Author
|
While looking into this I came across more code generation differences between the compilers like llvm/llvm-project#53268. |
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.
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.