Fix dropouts due to vector resize during long benchmarks#160
Merged
YaacovHazan merged 2 commits intoredis:masterfrom Aug 2, 2021
Merged
Fix dropouts due to vector resize during long benchmarks#160YaacovHazan merged 2 commits intoredis:masterfrom
YaacovHazan merged 2 commits intoredis:masterfrom
Conversation
YaacovHazan
approved these changes
Aug 2, 2021
Collaborator
|
Merged, thanks @JohnSully |
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 current implementation collects stats in a std::vector. As the vector grows it needs to be resized, during long runs this resize can take significant amounts of time and appear to the user as though the server is not responding. This is both inacurate and confusing to users using the tool.
The chart below clearly demonstrates the problem during a long run against redis. You can see big dropouts around 208, 520, 2080, 4056 seconds, profiler shows this time is spent in memmove during a vector resize.

The Fix
During the benchmark its critical that updating stats takes a constant time. Otherwise the benchmark results will be skewed. Because of this a std::vector with its O(n) insert is not the correct datastructure. The fix changes the code to a std::list which can guarantee O(1) inserts resulting in a more accurate benchmark.
The run with the fix achieved 159022 sets/s, while the original code produced 158304 sets/s
memtier command:
-t 50 -c 8 -n 2000000 -d 256 --key-minimum=1 --key-maximum=800000000 --ratio 1:0 --key-pattern=P:P --hide-histogram --json-out-file=redis.json