Whamcloud - gitweb
LU-16169 e2fsck: improve parallel thread balance
authorAndreas Dilger <adilger@whamcloud.com>
Sat, 8 Oct 2022 06:02:49 +0000 (00:02 -0600)
committerLi Dongyang <dongyangli@ddn.com>
Fri, 24 May 2024 11:03:20 +0000 (21:03 +1000)
commit4b58f7f23b96eae414fbe3cf2d97b6f6d3b67b14
treec3fe0fc41ad896f8bd5298d8d57f0201c77f163e
parentf85fb35d00c53cdd200f902b3a2d83e416b19a32
LU-16169 e2fsck: improve parallel thread balance

Improve the balance of work allocated to each thread by distributing
a more equal number of inodes to each thread, rather than an equal
number of groups.

In some cases in real usage, the number of inodes allocated to
threads with equal numbers of groups can vary by 10x or more, which
leads to pass1 threads having a runtime time roughly propritional
to the number of inodes allocated to them.

Calculate the average number of *used* inodes for each thread to
process instead of the overall average number of inodes in the
filesystem per thread.  Otherwise, if the filesystem is not very
full it will allocate too many groups to the first threads and
none to the last threads.

For example, a filesystem with a total of 5242880 inodes, with
3789293 used inodes should process on average 473661 used inodes
per thread with 8 threads, but this wasn't the case:

    # e2fsck -fn -m8 /dev/vgmyth/lvmythmdt0.ssd
    Pass 1: Checking inodes, blocks, and sizes
    [Thread 0] Scan group range [0, 20), inode_count = 655358/655360
    [Thread 1] Scan group range [20, 40), inode_count = 655360/655360
    [Thread 2] Scan group range [40, 66), inode_count = 647340/655360
    [Thread 3] Scan group range [66, 92), inode_count = 651555/655360
    [Thread 4] Scan group range [92, 112), inode_count = 655360/655360
    [Thread 5] Scan group range [112, 160), inode_count = 524320/655360
    [Thread 6] Scan group range [159, 160), inode_count = 0/655360
    [Thread 7] Scan group range [159, 160), inode_count = 0/655360

With the fix the thread balance is much better, with each thread
processing approximately the same number of used inodes, even the
last thread which has more groups but with fewer used inodes:

    Pass 1: Checking inodes, blocks, and sizes
    [Thread 0] Scan group range [0, 13], used inodes 458750/458752
    [Thread 1] Scan group range [14, 28], used inodes 491520/491520
    [Thread 2] Scan group range [29, 42], used inodes 458752/458752
    [Thread 3] Scan group range [43, 63], used inodes 486191/688128
    [Thread 4] Scan group range [64, 84], used inodes 485024/688128
    [Thread 5] Scan group range [85, 98], used inodes 458752/458752
    [Thread 6] Scan group range [99, 113], used inodes 491520/491520
    [Thread 7] Scan group range [114, 159], used inodes 458784/1507328

Also print the group ranges as closed sets so the brackets align.

Change-Id: Iea964cca33d19170e9b6d88aa725dc878cae6ce2
Reviewed-on: https://review.whamcloud.com/48806
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
e2fsck/e2fsck.h
e2fsck/pass1.c
tests/f_multithread/expect.1
tests/f_multithread_logfile/expect.1
tests/f_multithread_no/expect.1