Skip to content

Fix dropouts due to vector resize during long benchmarks#160

Merged
YaacovHazan merged 2 commits intoredis:masterfrom
JohnSully:master
Aug 2, 2021
Merged

Fix dropouts due to vector resize during long benchmarks#160
YaacovHazan merged 2 commits intoredis:masterfrom
JohnSully:master

Conversation

@JohnSully
Copy link
Contributor

@JohnSully JohnSully commented Jul 31, 2021

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.
image

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.

image

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

@YaacovHazan YaacovHazan merged commit 820605c into redis:master Aug 2, 2021
@YaacovHazan
Copy link
Collaborator

Merged, thanks @JohnSully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants