openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.69k stars 1.76k forks source link

abd scatter stats grow unbounded #16728

Closed mmaybee closed 3 weeks ago

mmaybee commented 3 weeks ago

System information

Type Version/Name
Distribution Name Ubuntu
Distribution Version 20.4
Kernel Version 5.15.0-119
Architecture x86_64
OpenZFS Version zfs-2.2.99

Describe the problem you're observing

Under a prolonged IO load the arc appears to deteriorate in performance. Telltale signs include the arc size remaining "large", but the size of the MRU and MFU shrink until the arc is spending 100% CPU time in arc_evict(). The available system memory size also appears out-of-wack wrt the arc size.

The issue is that the recent changes in the os-specific abd code related to DirectIO removed the call to abd_update_scatter_stats() in abd_free_linear_page() to decrement the stats counters (and the waste), so we continue to consume waste overhead without ever returning the space back to the arc.

Describe how to reproduce the problem

This is probably easiest to reproduce by running with a small arc size to begin with, as the size change will occur more quickly.

Include any warning/errors/backtraces from the system logs

For example, arc stats might look like this on a 256GB system:

$ arcstat 60
    time  read  ddread  ddh%  dmread  dmh%  pread  ph%   size      c  avail
17:07:58   0.0     0.0   0.0     0.0   0.0    0.0  0.0   195G   177G   194G
17:08:58  169K   35.7K  98.0   97.5K   100  35.7K  0.0   213G   213G   174G
17:09:58  363K   77.3K   100  208.8K   100  77.3K  0.0   242G   242G   145G
17:10:58  410K   99.4K  96.7  211.3K  97.8   100K  0.0   247G   247G   150G
17:11:58  423K  104.4K  97.0  214.2K  97.9   104K  0.0   247G   247G   163G
17:12:58  420K  103.4K  96.7  212.8K  97.9   104K  0.0   247G   247G   177G
17:13:58  111K   27.7K  78.2   56.3K  98.3  27.4K  0.0   249G   247G   178G  <--- arc perf drops off
17:14:58   28K    6.9K   0.1   14.1K   100   6.8K  0.0   250G   247G   178G
17:15:58   27K    6.6K   0.2   13.5K   100   6.6K  0.0   251G   247G   178G
17:16:58   27K    6.7K   0.2   13.6K   100   6.6K  0.0   252G   247G   178G
17:17:58   27K    6.7K   0.2   13.7K   100   6.7K  0.0   253G   247G   179G
17:18:58   26K    6.5K   0.2   13.4K   100   6.5K  0.1   254G   247G   179G
17:19:59   27K    6.6K   0.7   13.7K   100   6.6K  0.2   256G   247G   179G
17:20:59   27K    8.0K  20.6   13.1K   100   6.3K  0.1   256G   247G   179G
17:21:59   27K    6.8K   0.6   13.8K   100   6.7K  0.0   258G   247G   179G
17:22:59   25K    5.7K   0.8   13.6K  88.2   5.7K  0.0   259G   247G   179G
...
bwatkinson commented 3 weeks ago

@mmaybee I just opened #16729 to address this. Can you give it a spin and let me know this solves the issue observed?