• Binbin's avatar
    Optimize dict expand check, move allow check after the thresholds check (#12789) · 46347693
    Binbin authored
    dictExpandAllowed (for the main db dict and the expire dict) seems to
    involve a few function calls and memory accesses, and we can do it only
    after the thresholds checks and can get some performance improvements.
    
    A simple benchmark test: there are 11032768 fixed keys in the database,
    start a redis-server with `--maxmemory big_number --save ""`,
    start a redis-benchmark with `-P 100 -r 1000000000 -t set -n 5000000`,
    collect `throughput summary: n requests per second` result.
    
    After five rounds of testing:
    ```
    unstable     this PR
    848032.56    897988.56
    854408.69    913408.88
    858663.94    914076.81
    871839.56    916758.31
    882612.56    920640.75
    ```
    
    We can see a 5% performance improvement in general condition.
    But note we'll still hit the degradation when we over the thresholds.
    46347693
dict.c 61.7 KB