Device removal allocates a new location for each allocated segment on
the disk that's being removed.  Each allocation results in one entry in
the mapping table, which maps from old location + length to new
location.  When a fragmented disk is removed, this can result in a large
number of mapping entries, and thus a large amount of memory consumed by
the mapping table.  In the worst real-world cases, we've seen around 1GB
of RAM per 1TB of storage removed.

We can improve on this situation by allocating larger segments, which
span across both allocated and free regions of the device being removed.
By including free regions in the allocation (and thus mapping), we
reduce the number of mapping entries.  For example, if we have a 4K
allocation followed by 1K free and then 4K allocated, we would allocate
4+1+4 = 9KB, and then move the entire region (including allocated and
free parts).  In this case we used one mapping where previously we would
have used two, but often the ratio is much higher (up to 20:1 in
real-world use).  We then need to mark the regions that were free on the
removing device as free in the new locations, and also obsolete in the
mapping entry.

This method preserves the fragmentation of the removing device, rather
than consolidating its allocated space into a small number of chunks
where possible.  But it results in drastic reduction of memory used by
the mapping table - around 20x in the most-fragmented cases.

In the most fragmented real-world cases, this reduces memory used by the
mapping from ~1GB to ~50MB of RAM per 1TB of storage removed.  Less
fragmented cases will typically also see around 50-100MB of RAM per 1TB
of storage.

External-issue: DLPX-57962
You can view, comment on, or merge this pull request online at:

  https://github.com/openzfs/openzfs/pull/627

-- Commit Summary --

  * 9486 reduce memory used by device removal on fragmented pools

-- File Changes --

    M usr/src/uts/common/fs/zfs/range_tree.c (23)
    M usr/src/uts/common/fs/zfs/sys/range_tree.h (3)
    M usr/src/uts/common/fs/zfs/sys/vdev_removal.h (3)
    M usr/src/uts/common/fs/zfs/vdev_label.c (23)
    M usr/src/uts/common/fs/zfs/vdev_removal.c (200)

-- Patch Links --

https://github.com/openzfs/openzfs/pull/627.patch
https://github.com/openzfs/openzfs/pull/627.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openzfs/openzfs/pull/627

------------------------------------------
openzfs: openzfs-developer
Permalink: 
https://openzfs.topicbox.com/groups/developer/discussions/Tcb3e8755498aa70a-M5acd5eb442e3ac18c5ec0e61
Delivery options: https://openzfs.topicbox.com/groups

Reply via email to