Reduce capacity to stay within multi-pool allocator ceiling - #415
Open
cameron314 wants to merge 1 commit into
Open
Reduce capacity to stay within multi-pool allocator ceiling#415cameron314 wants to merge 1 commit into
cameron314 wants to merge 1 commit into
Conversation
…ue heap allocations on interleaved calls to execute()/announce())
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.
The deferred functor queue maintained by
Chronologyis swapped out with an empty container when it is drained byannounce(). The next call toexecute()re-reserves capacity for many functors. The intention was for the backing memory to come from the multi-pool allocator (making the pattern of reserve-swap-reserve-swap-... much cheaper). However, the chosen capacity was larger than the maximum size of the multi-pool, causing it to perform a true heap allocation/deallocation on each cycle, which was significantly more expensive.I've changed the constant and added an assertion to insure against future regressions. I've verified the assertion fails while running the unit tests with the original constant.
Note that on a 64-bit test machine,
sizeof(bsl::function<void()>)is currently 80 bytes.Empirical testing shows the following reduction in overhead:
Before: 118 samples, heap allocations

After: 108 samples, pool allocations