]> git.proxmox.com Git - mirror_zfs.git/commit
looping in metaslab_block_picker impacts performance on fragmented pools
authorMatthew Ahrens <mahrens@delphix.com>
Thu, 13 Jun 2019 20:06:15 +0000 (13:06 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 13 Jun 2019 20:06:15 +0000 (13:06 -0700)
commitd3230d761ac6234ad20c815f0512a7489f949dad
treecd6c400cffefb7a09def36f62d02c542cd4db079
parent9c7da9a95aaaecced0a1cfc40190906e7a691327
looping in metaslab_block_picker impacts performance on fragmented pools

On fragmented pools with high-performance storage, the looping in
metaslab_block_picker() can become the performance-limiting bottleneck.
When looking for a larger block (e.g. a 128K block for the ZIL), we may
search through many free segments (up to hundreds of thousands) to find
one that is large enough to satisfy the allocation. This can take a long
time (up to dozens of ms), and is done while holding the ms_lock, which
other threads may spin waiting for.

When this performance problem is encountered, profiling will show
high CPU time in metaslab_block_picker, as well as in mutex_enter from
various callers.

The problem is very evident on a test system with a sync write workload
with 8K writes to a recordsize=8k filesystem, with 4TB of SSD storage,
84% full and 88% fragmented. It has also been observed on production
systems with 90TB of storage, 76% full and 87% fragmented.

The fix is to change metaslab_df_alloc() to search only up to 16MB from
the previous allocation (of this alignment). After that, we will pick a
segment that is of the exact size requested (or larger). This reduces
the number of iterations to a few hundred on fragmented pools (a ~100x
improvement).

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
External-issue: DLPX-62324
Closes #8877
man/man5/zfs-module-parameters.5
module/zfs/metaslab.c