Fix performace issue - #4
Merged
Merged
Conversation
torrentg
commented
Jun 22, 2024
Owner
Impressive improvement ! |
372046933
commented
Jun 23, 2024
ContributorAuthor
Thank you for your review. Does |
torrentg
commented
Jun 24, 2024
Owner
You are welcome. Yes, shrink_to_fit and the constructor with fixed capacity breaks the power of two garantee. This was reported by some tests that failed. I suspect that usual usage case don't use this features, this is because I set a [likely] in the power of two case. |
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 freeto 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.
GCC default optimization level is 0, i.e. no optimization. Production environment usually has optimization level at least 2.
When
-O3is used,cqueueis three times slower thanstd::deque. The root cause is modulo operator. Every push/pop needs to moduloreserved_.Since
reserved_is always power of 2. Modulo can be replaced by bit operation.Before the PR
After: