Skip to content
  • Qu Wenruo's avatar
    btrfs: qgroup: Only trace data extents in leaves if we're relocating data block group · 3d0174f7
    Qu Wenruo authored
    
    
    For qgroup_trace_extent_swap(), if we find one leaf that needs to be
    traced, we will also iterate all file extents and trace them.
    
    This is OK if we're relocating data block groups, but if we're
    relocating metadata block groups, balance code itself has ensured that
    both subtree of file tree and reloc tree contain the same contents.
    
    That's to say, if we're relocating metadata block groups, all file
    extents in reloc and file tree should match, thus no need to trace them.
    This should reduce the total number of dirty extents processed in metadata
    block group balance.
    
    [[Benchmark]] (with all previous enhancement)
    Hardware:
    	VM 4G vRAM, 8 vCPUs,
    	disk is using 'unsafe' cache mode,
    	backing device is SAMSUNG 850 evo SSD.
    	Host has 16G ram.
    
    Mkfs parameter:
    	--nodesize 4K (To bump up tree size)
    
    Initial subvolume contents:
    	4G data copied from /usr and /lib.
    	(With enough regular small files)
    
    Snapshots:
    	16 snapshots of the original subvolume.
    	each snapshot has 3 random files modified.
    
    balance parameter:
    	-m
    
    So the content should be pretty similar to a real world root fs layout.
    
                         | v4.19-rc1    | w/ patchset    | diff (*)
    ---------------------------------------------------------------
    relocated extents    | 22929        | 22851          | -0.3%
    qgroup dirty extents | 227757       | 140886         | -38.1%
    time (sys)           | 65.253s      | 37.464s        | -42.6%
    time (real)          | 74.032s      | 44.722s        | -39.6%
    
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    3d0174f7