Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use hashtable as the default type of temp set object during sunion/sd…
…iff (valkey-io#996) This patch try to set the temp set object as default hash table type. And did a simple predication of the temp set object encoding when initialize `dstset` to reduce the unnecessary conversation. ## Issue Description According to existing code logic, when did operation like `sunion` and `sdiff` , the temp set object could be `intset`, `listpack` and `hashtable`, for the `listpack`, the efficiency is low when did operation like `find` and `compare` , need to traverse all elements. When we exploring the hotspots, found the `lpFind` and `memcmp` has been the bottleneck when running workloads like below: - [memtier_benchmark-2keys-set-10-100-elements-sunion.yml](https://github.com/redis/redis-benchmarks-specification/blob/main/redis_benchmarks_specification/test-suites/memtier_benchmark-2keys-set-10-100-elements-sunion.yml) - [memtier_benchmark-2keys-set-10-100-elements-sdiff.yml](https://github.com/redis/redis-benchmarks-specification/blob/main/redis_benchmarks_specification/test-suites/memtier_benchmark-2keys-set-10-100-elements-sdiff.yml) ![image](https://github.com/user-attachments/assets/71dfc70b-2ad5-4832-a338-712deefca20e) ## Optimization This patch try to set the temp set object as default hash table type. And did a simple predication of the temp set object encoding when initialize `dstset` to reduce the unnecessary conversation. ### Test Environment - OPERATING SYSTEM: Ubuntu 22.04.4 LTS - Kernel: 5.15.0-116-generic - PROCESSOR: Intel Xeon Platinum 8380 - Server and Client in same socket. #### Server Configuration ``` taskset -c 0-3 ~/valkey/src/valkey-server /tmp/valkey.conf port 9001 bind * -::* daemonize no protected-mode no save "" ``` #### Performance Boost | Test Name| Perf Boost| |-|-| |[memtier_benchmark-2keys-set-10-100-elements-sunion.yml](https://github.com/redis/redis-benchmarks-specification/blob/main/redis_benchmarks_specification/test-suites/memtier_benchmark-2keys-set-10-100-elements-sunion.yml) |41%| |[memtier_benchmark-2keys-set-10-100-elements-sdiff.yml](https://github.com/redis/redis-benchmarks-specification/blob/main/redis_benchmarks_specification/test-suites/memtier_benchmark-2keys-set-10-100-elements-sdiff.yml) |27%| ### More Tests With above test set which have total 110 elements in the 2 given sets. We also did some benchmarking by adjusting the total number of elements in all given sets. We can still observe the performance boost. ![image](https://github.com/user-attachments/assets/b2ab420c-43e5-45de-9715-7d943df229cb) --------- Signed-off-by: Lipeng Zhu <[email protected]> Co-authored-by: Wangyang Guo <[email protected]>
- Loading branch information