Skip to contentSkip to conversation

slab: Redis loopback throughput drops 40% after the sheaves merge, list_lock contention

REGRESSION Garg, Shivank 2 participants 2 messages Dec 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

On a 2-socket AMD EPYC Zen 6 system, a Redis/memtier benchmark over loopback TCP loses about 40% of its throughput with the slab-for-7.0 merge (148f95f75c51) and has not recovered as of v7.4-rc4.

Hao Li's slab parking RFC [1] recovers most of the throughput, but the refill side still contends on that lock. Pedro asked in that thread why the slow paths are hit so hard [2]; this workload may be a useful data point.

Kernels:
K1: 41f1a08645ab (just before the slab-for-7.0 merge)
K2: 148f95f75c51 (Merge tag 'slab-for-7.0')
K3: v7.4-rc4
K4: v7.4-rc4 + slab parking RFC 2/2 [1]

The cache-aware scheduler (CONFIG_SCHED_CACHE, llc_balancing) was added in v7.2 and changes the scores of K3 and K4, so both settings of /sys/kernel/debug/sched/llc_balancing/enabled are shown. K1 and K2 do not have it.

Results (128 Redis instances, ops/s, higher is better)
------------------------------------------------------

  kernel                     score    imbalance
  K1                         35.3M    4-6%
  K2                         21.2M    2%
                             llc_balancing off     llc_balancing on
  K3                         18.1M    4%           20.9M    3%
  K4                         31.1M    16-19%       34.0M    5-8%

Imbalance = 1 - (slowest instance / average instance), i.e. how far the slowest Redis instance falls behind the average one. K3 and K4 were measured in the same session, two runs each.

The drop in score comes from e323b52cf00f ("slab: remove SLUB_CPU_PARTIAL"), where allocation stops using CPU slabs.

The workload do not have to cross sockets to see regression. With each memtier on node 1 (the servers' socket) instead of node 2, llc_balancing off:

                             cross-socket    same socket
  K1 (+026dfef287c0)         35.5M           43.3M
  K3                         18.5M           22.7M
  K4                         31.1M           42.7M

(Without 026dfef287c0 "tcp: give up on stronger sk_rcvbuf checks (for now)", two clients hang in warm-up on K1 in this placement.)

IBS profiles
------------

perf record -e ibs_op// -F 99 -g for 30 s during the measured phase, on the server CPUs and the client node:
Share of all samples by the call path that took the lock:

                                      K1           K2         K3        K4
  native_queued_spin_lock_slowpath    0.26%        49.6%      51.0%     7.4%
    __slab_free (from tcp_ack)        0.00%        19.6%      23.2%     0.0%
    __refill_objects_node             0.00%        13.8%      21.8%     6.5%
    __slab_free (from refill)         0.00%         9.4%       0.0%     0.0%
    lock_sock                         0.21%         6.5%       6.0%     0.9%

perf lock contention -ab -l for 60 s, in a separate run (scores are 6-10% lower while tracing). Contentions and wait time summed over the kmem_cache_node locks; average and maximum wait for the busiest one:

                       contended   total wait  avg wait  max wait
  K1                   42.5K       0.50 s      12 us     38 us
  K2                   26.9M       2.44 h      333 us    512 us
  K3                   28.9M       2.36 h      304 us    498 us
  K4                   16.6M       0.60 h      171 us    1.35 ms

SLUB stats
----------

Raw deltas of /sys/kernel/slab/<cache>/<stat> between two snapshots taken around the 30 s IBS recording, for the three caches that carry nearly all slab traffic here (every other cache is about 1000x smaller). Counters that stayed zero on all four kernels are omitted;

                                 K1           K2           K3           K4
window (s)                       46.6         46.7         45.6         45.7

score (ops/s) 35478084 20686973 18704350 30338628

skbuff_small_head
alloc_fastpath 858637817 501674273 451686818 777803866
alloc_slowpath 20533599 402533 0 0

  free_fastpath             362550811    298845067    264494949    468618930
  free_slowpath             516620401    203233941    187193140    309184878
  free_frozen               291872511            0            0            0
  free_add_partial            2508876     16366857     12554973     20654336
  free_remove_partial             473           15            3           84
  alloc_from_partial           908862            0            0            0
  alloc_slab                   865539           16            0           82
  alloc_refill               15614960            0            0            0
  free_slab                    865505           15            3           84
  deactivate_empty             865041            0            0            0
  deactivate_bypass           4918651            0            0            0
  cmpxchg_double_cpu_fail            1            0            0            0
  cmpxchg_double_fail         7046923      8985001      9870156      4350514
  cpu_partial_alloc           3144255            0            0            0
  cpu_partial_free            4918642            0            0            0
  cpu_partial_node            1599546            0            0            0
  cpu_partial_drain           1124639            0            0            0
  sheaf_flush                       0           84            0          308
  sheaf_refill                      0    202831496    187193972    309185436
  sheaf_alloc                       0            1            1            0
  barn_get                          0      1735293      1192686       513887
  barn_get_fail                     0      7646517      6685533     11042351
  barn_put                          0      1735288      1192679       513886
  barn_put_fail                     0            3            0           11

skbuff_fclone_cache (merged by SLUB into :0000512 with pool_workqueue,
sgpool-16 and others; counters are for the whole merged cache)
alloc_fastpath 811658540 472356054 419678959 712136406
alloc_slowpath 12159236 8 0 0

  free_fastpath             428713955    272135099    234237555    418284975
  free_slowpath             395104003    200220715    185442322    293851863
  free_frozen               391353926            0            0            0
  free_add_partial              31450     12394163      9752769     11922064
  free_remove_partial              90           10            6           36
  alloc_from_partial            12318            0            0            0
  alloc_slab                     4384           13            3           39
  alloc_refill               12100009            0            0            0
  alloc_node_mismatch               7            7            0            0
  free_slab                      4417           10            6           36
  deactivate_empty               4327            0            0            0
  deactivate_to_head                6            0            0            0
  deactivate_to_tail                1            0            0            0
  deactivate_remote_frees           1            0            0            0
  deactivate_bypass             59266            0            0            0
  cmpxchg_double_cpu_fail            1            0            0            0
  cmpxchg_double_fail          133519       510080       803684      2407007
  cpu_partial_alloc             42578            0            0            0
  cpu_partial_free              59266            0            0            0
  cpu_partial_node              19054            0            0            0
  cpu_partial_drain             17885            0            0            0
  sheaf_refill                      0    200221112    185442404    293852272
  sheaf_alloc                       0            7            5            2
  barn_get                          0       899214       593667       258897
  barn_get_fail                     0      7150760      6622971     10494696
  barn_put                          0       899225       593666       258895

skbuff_head_cache
alloc_fastpath 55537635 26508172 32025447 64377421
alloc_slowpath 16513 3045585 0 0
free_fastpath 54497205 26508028 30208694 49095037
free_slowpath 1056943 3045710 1816671 15282404
free_frozen 1056701 0 0 0
free_add_partial 2 46117 22579 310801

  alloc_refill                  16512            0            0            0
  deactivate_bypass                 4            0            0            0
  cmpxchg_double_fail               2        84247          352        14362
  cpu_partial_alloc                 4            0            0            0
  cpu_partial_free                  4            0            0            0
  cpu_partial_drain                 1            0            0            0
  free_remove_partial               0            2            1            4
  free_slab                         0            2            1            4
  barn_get                          0           19            4            4
  barn_get_fail                     0      3045628        64877       545801
  barn_put                          0           17            2            3
  sheaf_refill                      0            0      1816556     15282260

Setup
-----

Machine: AMD EPYC Zen 6, 2-socket, 256 cores per socket, SMT2, NPS2.

          8 CCDs per socket, 32 cores per CCD. Core clock fixed at
          2.0 GHz.

            NUMA node0 CPU(s):   0-127,512-639     (socket 0)
            NUMA node1 CPU(s):   128-255,640-767   (socket 0)
            NUMA node2 CPU(s):   256-383,768-895   (socket 1)
            NUMA node3 CPU(s):   384-511,896-1023  (socket 1)

            node distances:
              node   0   1   2   3
                0:  10  12  32  32
                1:  12  10  32  32
                2:  32  32  10  12
                3:  32  32  12  10

Kernels: the mainline commits listed above.
Default systemd cgroup layout, no memory limits.

Workload: Redis 7.0.11 and memtier_benchmark 2.1.2 over loopback TCP.

          128 redis-servers, one per core on cores 0-127 (node 0); one
          memtier per server, allowed anywhere in node 2 (socket 1).

          Server i (i = 0..127):
            numactl -C $i -m 0 -- redis-server redis.conf --save "" \
                --port $((6300+i))
            (redis.conf: bind 127.0.0.1, appendonly no)

          Client i, warm-up:
            numactl -C 256-383,768-895 -m 2 -- \
              memtier_benchmark -s 127.0.0.1 --port $((6300+i)) \
                -n allkeys --data-size=2048 --key-prefix A \
                --key-minimum=1 --key-maximum=8000000 \
                --key-pattern G:G --key-stddev=180000 \
                --distinct-client-seed -c 2 -t 2 --pipeline 150 \
                --ratio=1:0
          Client i, measured (120 s): the same with --test-time 120
            --ratio=1:10 instead of -n allkeys --ratio=1:0

          Score: sum of the Ops/sec on each memtier's "Totals" line.

Is there a plan for reviving the parking patchset[1] or any other fix to target this issue. I am happy to test patches or collect more data on this system.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/apBioBxd4VkmaGhA@pedro-suse/

Thanks,
Shivank

#1 lore raw
Quoted 5 lines · Shivank

Hi,

On a 2-socket AMD EPYC Zen 6 system, a Redis/memtier benchmark over loopback TCP loses about 40% of its throughput with the slab-for-7.0 merge (148f95f75c51) and has not recovered as of v7.4-rc4.

Hello, Shivank,

Thanks for sharing this performance report.

Quoted 5 lines

Hao Li's slab parking RFC [1] recovers most of the throughput, but the refill side still contends on that lock. Pedro asked in that thread why the slow paths are hit so hard [2]; this workload may be a useful data point.

This is interesting!

Quoted 3 lines

Kernels:
K1: 41f1a08645ab (just before the slab-for-7.0 merge)

I took a look at this commit and noticed it already has both percpu slabs and sheaves (i.e., an additional percpu cache layer on top of the sheaves layer). So in theory, this commit should have the best performance.

Quoted 1 line

K2: 148f95f75c51 (Merge tag 'slab-for-7.0')

After this commit, the percpu layer is completely removed, so in theory, some performance drop is expected here. Because of that, the data from K1 may not be the best reference for comparison. Just to be on the safe side, would you mind testing commit 9d4e6ab865c4 (e.g. naming it K0) as well, which represents the state before the sheaves mechanism was introduced? Thanks!

Quoted 7 lines

K3: v7.4-rc4
K4: v7.4-rc4 + slab parking RFC 2/2 [1]

The cache-aware scheduler (CONFIG_SCHED_CACHE, llc_balancing) was added in v7.2 and changes the scores of K3 and K4, so both settings of /sys/kernel/debug/sched/llc_balancing/enabled are shown. K1 and K2 do not have it.

That's a very helpful point as well. In addition, I will take a closer look at the detailed performance metrics in the report, and if possible, I'll also try to reproduce the results locally. Thanks!

Signature · 2 lines
Thanks,
Hao