Skip to content

Commit

Permalink
Improve sorted scan memory accounting
Browse files Browse the repository at this point in the history
Since we use two B-trees q_exts_by_size and q_exts_by_addr, we should
count 2x sizeof (range_seg_gap_t) per node.  And since average B-tree
memory efficiency is about 75%, we should increase it to 3x.

Previous code under-counted up to 30% of the memory usage.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Alexander Motin <[email protected]>
Sponsored-By: iXsystems, Inc.
Closes #13537
  • Loading branch information
amotin authored Jun 10, 2022
1 parent 4ed5e25 commit 87b46d6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions module/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,9 +1276,12 @@ dsl_scan_should_clear(dsl_scan_t *scn)
mutex_enter(&tvd->vdev_scan_io_queue_lock);
queue = tvd->vdev_scan_io_queue;
if (queue != NULL) {
/* # extents in exts_by_size = # in exts_by_addr */
/*
* # of extents in exts_by_size = # in exts_by_addr.
* B-tree efficiency is ~75%, but can be as low as 50%.
*/
mused += zfs_btree_numnodes(&queue->q_exts_by_size) *
sizeof (range_seg_gap_t) + queue->q_sio_memused;
3 * sizeof (range_seg_gap_t) + queue->q_sio_memused;
}
mutex_exit(&tvd->vdev_scan_io_queue_lock);
}
Expand Down

0 comments on commit 87b46d6

Please sign in to comment.