Skip to content

f2fs: improve performance of NAT/SIT flushing during cp

Hou Pengyang linux-f2fs-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest5 patches 4 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5f2fs: use bucket sort to avoid tree lookup and list sort when nat flushingfs/f2fs/f2fs.h fs/f2fs/node.c+24 -342 replies
1/5f2fs: use bucket sort to avoid tree lookup and list sort when nat flushingfs/f2fs/f2fs.h fs/f2fs/node.c+22 -330 replies
2/5f2fs: reconstruct sit flushing codefs/f2fs/segment.c+64 -550 replies
3/5f2fs: use bucket sort to avoid list sort when flush sit entriesfs/f2fs/f2fs.h fs/f2fs/segment.c fs/f2fs/segment.h+32 -250 replies
4/5f2fs: avoid unnecessary to_journal checkingfs/f2fs/node.c+14 -130 replies
5/5f2fs: use an array to record sit_entry_set info to make sort fastfs/f2fs/f2fs.h fs/f2fs/segment.c fs/f2fs/segment.h+26 -520 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/5] f2fs: improve performance of NAT/SIT flushing during cp

This patches are to designed to optimize NAT/SIT flushing procedure:

patch 1) -- patch 3):

during flush_nat_entries, we do:
1) gang_lookup a radix tree, find all the dirty nat_entry_set;
2) sort nat_entry_set by nat_entry_set->entry_cnt, in order to write to journal as much as possible to avoid unnessary IO.

This patch optimize the look_up & sort algorithm by introducing an array:

f2fs_nm_info->dirty_set[NAT_ENTRY_PER_BLOCK+1]; (struct list_head dirty_set[NAT_ENTRY_PER_BLOCK + 1])

dirty_set[1] links all nat_entry_set whose entry_cnt is 1 dirty_set[2] links all nat_entry_set whose entry_cnt is 2
......
dirty_set[N] links all nat_entry_set whose entry_cnt is N

as one NAT block has NAT_ENTRY_PER_BLOCK entries at MOST, so there should NOT be one nat_entry_set whose entry_cnt is larger than NAT_ENTRY_PER_BLOCK.

So it is enough for f2fs_nm_info->dirty_set to link all nat_entry_sets in system.

Update:

    we update nat_entry_set in real-time, e.g originally nat_entry_set->entry_cnt is

1, and licked by dirty_set[1]; then call __set_nat_cache_dirty to increase nat_entry's entry_cnt, we move this nat_entry_set ot dirty_set[2]'s tail, no need to compare.

Flush:
when flush dirty nat_entry_set, we just flush nat_entry_set from
f2fs_nm_info->dirty_set[0] to f2fs_nm_info->dirty_set[NAT_ENTRY_PER_BLOCK], where gang_lookup and sort can be avoid.

footprint of this algorithm: sizeof(struct list_head)*NAT_ENTRY_PER_BLOCK

                              = 8*455 = 3.6k bytes

Same for SIT.

In patch 5), we use array to manage sit_entry_sets instead of list, which can avoid list travel, and there is no need to alloc/free lab memory. It is low footrpint consuming.

Hou Pengyang (5):
f2fs: use bucket sort to avoid tree lookup and list sort when nat flushing
f2fs: reconstruct sit flushing code
f2fs: use bucket sort to avoid list sort when flush sit entries
f2fs: avoid unnecessary to_journal checking
f2fs: use an array to record sit_entry_set info to make sort fast

 fs/f2fs/f2fs.h    |   5 +-
 fs/f2fs/node.c    |  79 ++++++++-----------
 fs/f2fs/segment.c | 227 ++++++++++++++++++++++++++----------------------------
 fs/f2fs/segment.h |   2 +-
 4 files changed, 147 insertions(+), 166 deletions(-)
Signature · 6 lines
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot