#13929·Redis

[BUG] ZUNIONSTORE Command Performance Degradation After Commit 5358bd7

Author: JinzeSiCreated Apr 9, 2025Updated Sep 17, 2026

Describe the bug

I have recently done some performance research on the redis code. Finding a noticeable performance degradation has been observed in the ZUNIONSTORE command after the introduction of commit 5358bd7. Benchmark results indicate that the performance of ZUNIONSTORE has worsened, particularly when handling large sorted sets.

To reproduce

  1. Use the following command to benchmark the performance of ZUNIONSTORE:
memtier_benchmark \
  --pipeline 50 \
  --command "ZUNIONSTORE tmp 50 key_SortSet:571 key_SortSet:8922 key_SortSet:23 key_SortSet:5678 key_SortSet:12 key_SortSet:4398 key_SortSet:456 key_SortSet:9546 key_SortSet:71 key_SortSet:897 \
  key_SortSet:171 key_SortSet:1922 key_SortSet:13 key_SortSet:1678 key_SortSet:22 key_SortSet:1398 key_SortSet:156 key_SortSet:1546 key_SortSet:11 key_SortSet:197 \
  key_SortSet:271 key_SortSet:2922 key_SortSet:33 key_SortSet:2678 key_SortSet:32 key_SortSet:2398 key_SortSet:256 key_SortSet:2546 key_SortSet:21 key_SortSet:297 \
  key_SortSet:371 key_SortSet:3922 key_SortSet:43 key_SortSet:3678 key_SortSet:42 key_SortSet:3398 key_SortSet:356 key_SortSet:3546 key_SortSet:31 key_SortSet:397 \
  key_SortSet:471 key_SortSet:4922 key_SortSet:53 key_SortSet:4678 key_SortSet:52 key_SortSet:5398 key_SortSet:556 key_SortSet:4546 key_SortSet:41 key_SortSet:497" \
  --test-time 150 \
  -c 50 \
  -t 4 \
  --hide-histogram \
  -x 5
  1. Compare the benchmark results before and after applying commit 5358bd7: Before 5358bd7

    AGGREGATED AVERAGE RESULTS (5 runs)
    ====================================================
    Type              Ops/sec      Latency       KB/sec 
    ----------------------------------------------------
    Zunionstores       230.99  38215.11920       259.86 
    Totals             230.99  38215.11920       259.86 
    

    After 5358bd7

    AGGREGATED AVERAGE RESULTS (5 runs)
    ====================================================
    Type              Ops/sec      Latency       KB/sec 
    ----------------------------------------------------
    Zunionstores       227.28  38791.16180       255.69 
    Totals             227.28  38791.16180       255.69
    

Steps to reproduce the behavior and/or a minimal code sample. just use memtier_benchmark

Expected behavior

The ZUNIONSTORE command should maintain or improve its performance after the changes introduced in commit 5358bd7. The commit was intended to optimize rehashing, not degrade the performance of operations like ZUNIONSTORE.

Additional information

NULL