-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cpp: re-use allocations for message indexes in writer
We use a hash map { channel ID: message index vector } to store message indexes while writing messages. For M messages in N channels in a chunk, there will always be N separately-allocated vectors containing on average M/N elements. Before this commit, we destroy and re-create these vectors for every chunk. With a large number of channels, this can result in many allocations and re-allocations as the vectors get rebuilt for every new chunk. After this commit, we clear the vectors after writing a chunk, allowing us to re-use the allocated memory for the next chunk. This should result in much less work for the allocator while writing. This commit also contains a new benchmark to demonstrate this behavior. I need to properly measure the results but i've eyeballed a small speedup around ~10% speedup for large numbers of channels.
- Loading branch information
Showing
2 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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