Experimental Environment
We conducted experiments to investigate how the size of the Key and Value affects Compaction.
Various Key Size | Various Value Size |
---|---|
16 byte | 256 byte |
32 byte | 1 kb |
64 byte | 4 kb |
128 byte | 16 kb |
For benchmarks, we utilized only fillrandom
and readrandom
where Compaction occurs.
Experiment Setup | Benchmarks |
---|---|
version 1.23 | fillrandom |
CPU Intel Xeon(R) | readrandom |
~~fillseq~~ | |
~~readseq~~ |
1. 'fillrandom' with Variable Key Size
In fillrandom
with variable key size, we expected the WAF latency to gradually increase. However, contrary to our expectations, the WAF decreased as the key size decreased.
2. 'fillrandom' with Variable Value Size
For variable value size, we anticipated that increasing the size by 4 times would result in a 4-fold performance difference. However, the results showed:
- Compaction latency increased by 5.18 times.
- Latency increased by 5.33 times.
This seems to be because as the value size increased, Compaction occurred more frequently.
3. 'readrandom' with Variable Key/Value Size
In readrandom
with variable value size, latency increased by more than 100 times at 4kb and 16kb.
Re-experiment Due to Unexpected Results
In the fillrandom
benchmark experiment, we found the rate of change in the graph inappropriate, prompting a re-experiment. We calculated the average of values obtained by repeating the same experiment three times and compared it with the previous experiment.
Re-experiment-1 'fillrandom' with Variable Key Size
Measured by the average of values repeated three times.
As a result, the WAF continued to decrease as in the previous experiment. Further research was conducted to understand why the WAF continued to decrease contrary to expectations.
Re-experiment-2 'fillrandom' with Variable Value Size
Measured by the average of values repeated three times. To ensure more accurate measurements, we subdivided the intervals further.
As a result, we obtained more precise results with latency decreasing from 5.33 times to 2.5 times.
Similarly, we calculated the average of values repeated three times and subdivided the intervals further for comparison.
As a result, we obtained more precise results with compaction latency decreasing from 5.18 times to 3.5 times.
Conclusion and Discussion
We conducted experiments based on the hypothesis that key/value size affects compaction. In the case of fillrandom
, as the value size increased, the number of values to be compacted increased, resulting in decreased throughput and increased WAF, latency, and compaction latency. In the case of readrandom
, as the value to be read at once increased, latency also increased.
The results from fillrandom
with increasing key size were peculiar. As the key size increased, the number of keys within that size remained the same, but the key range increased (see image below). Therefore, when compaction is triggered, the size to be loaded into memory, merge sorted, and written back to disk increased, leading to increased latency and compaction latency. However, since the number of keys within the range remained the same, the overlapping range was the same, allowing for more write processing over a larger range at once, resulting in decreased WAF and increased throughput.