• Harkrishn Patro's avatar
    Optimize client memory usage tracking operation while client eviction is disabled (#11348) · 05c9378b
    Harkrishn Patro authored
    
    
    ## Issue
    During the client input/output buffer processing, the memory usage is
    incrementally updated to keep track of clients going beyond a certain
    threshold `maxmemory-clients` to be evicted. However, this additional
    tracking activity leads to unnecessary CPU cycles wasted when no
    client-eviction is required. It is applicable in two cases.
    
    * `maxmemory-clients` is set to `0` which equates to no client eviction
      (applicable to all clients)
    * `CLIENT NO-EVICT` flag is set to `ON` which equates to a particular
      client not applicable for eviction.
    
    ## Solution
    * Disable client memory usage tracking during the read/write flow when
      `maxmemory-clients` is set to `0` or `client no-evict` is `on`.
      The memory usage is tracked only during the `clientCron` i.e. it gets
      periodically updated.
    * Cleanup the clients from the memory usage bucket when client eviction
      is disabled.
    * When the maxmemory-clients config is enabled or disabled at runtime,
      we immediately update the memory usage buckets for all clients (tested
      scanning 80000 took some 20ms)
    
    Benchmark shown that this can improve performance by about 5% in
    certain situations.
    Co-authored-by: default avatarOran Agra <oran@redislabs.com>
    (cherry picked from commit c0267b3f)
    05c9378b
debug.c 82.7 KB