Skip to content

Investigate percpu_arena performance characteristic #713

Open

Description

@interwq

We disabled percpu_arena by default in #848 because of performance regression observed in production testing. However, in the long term we still believe percpu_arena should be the right default and solve issues with the narenas = ncpus*4 currently.

Need further investigation to confirm what caused the regression. One possibility is that with producer-consumer model, we are getting a lot more lock contentions with less narenas.

Some lock data we got previously below:
From the mutex profiling data, percpu arena does change arena access pattern significantly.
Config: t-test1 128 threads on 32 cores. Pretty intense test params, took ~10 seconds to finish.
Merged arena mutex profiling w/ PerCPU arena enabled:

                           n_lock_ops       n_waiting      n_spin_acq  n_owner_switch   total_wait_ns     max_wait_ns  max_n_thds
large:                        5889785               9           12763         1409289        14000068        13000063           1
extent_freelist:               620257               0               1           72546               0               0           0
extents_dirty:               11798900              25           22239         1641618        60000294         7000034           6
extents_muzzy:                 533100               4              14           56768        28000137        16000078           4
extents_retained:             1065531             201              22           57796       880004266        19000092          44
decay_dirty:                    12586               0               1            9882               0               0           0
decay_muzzy:                    12572               0               0            9882               0               0           0
base:                          619994              63               9           72526       133000651        12000058           6
tcache_list:                    19585               4              58           18111         1000005         1000005           1

Merged arena mutex profiling w/ PerCPU arena disabled but narenas=32 (same as nCPUs):

                           n_lock_ops       n_waiting      n_spin_acq  n_owner_switch   total_wait_ns     max_wait_ns  max_n_thds
large:                        5076175               9           10925         1196090               0               0           1
extent_freelist:               483069               0             163          176135               0               0           0
extents_dirty:               11810985              17           37102         1338378         9000045         3000015           3
extents_muzzy:                 432023               3            5511          161733         4000020         2000010           2
extents_retained:              863379              41            5112          181127        18000091         2000010           5
decay_dirty:                    13954               0               0            9221               0               0           0
decay_muzzy:                    13939               0               0            9221               0               0           0
base:                          483216              29             951          176125        40000198         8000039           3
tcache_list:                      193               0               0             161               0               0           0

Some thoughts:

  1. tcache_list mutex operation gives us insights about thread migration. Unfortunately, it happens very often -- 19k operations means ~9.5k of migrations over ~10 seconds. This kills locality.
  2. num of lock contentions reduce significantly, if we look at n_spin + n_wait. For some locks, e.g. extents_muzzy, contention happened only 18 times with percpu arena, while >5k without.
  3. n_wait increased instead, as well as total wait time, and max wait time. Mainly from extents_retained and base, both showing that spin had little effect.
  4. large and extents_dirty are the only two mutexes still heavily contented w/ percpu arena (note the n_spin_acq). These are likely from "remote" arena access, which we probably can do something to optimize, e.g. if we are accessing a remote arena, don't touch stuff like extents_dirty.
  5. num of owner switch looks pretty interesting. I believe it does show some locality improvements, e.g. extents_muzzy and _retained. For cases that it does not show improvements, we probably can do better.
  6. There's some variance in total # of lock ops.

I'll do more experiments and think about things to try next.

Activity

  1. added this to the 5.0.0 milestone on Mar 23, 2017
  2. self-assigned this
    on Mar 23, 2017
  3. changed the title [-]PerCPU arena locking improvements[/-] [+]Investigate percpu_arena performance characteristic[/+] on May 23, 2017
  4. modified the milestones: 5.1.0, 5.0.0 on May 23, 2017
  5. modified the milestones: 5.1.0, 5.2.0 on Apr 11, 2018
  6. modified the milestones: 5.2.0, 6.0 on Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions