linux/fs/f2fs
Jin Xu a26b7c8a01 f2fs: optimize gc for better performance
This patch improves the gc efficiency by optimizing the victim
selection policy. With this optimization, the random re-write
performance could increase up to 20%.

For f2fs, when disk is in shortage of free spaces, gc will selects
dirty segments and moves valid blocks around for making more space
available. The gc cost of a segment is determined by the valid blocks
in the segment. The less the valid blocks, the higher the efficiency.
The ideal victim segment is the one that has the most garbage blocks.

Currently, it searches up to 20 dirty segments for a victim segment.
The selected victim is not likely the best victim for gc when there
are much more dirty segments. Why not searching more dirty segments
for a better victim? The cost of searching dirty segments is
negligible in comparison to moving blocks.

In this patch, it enlarges the MAX_VICTIM_SEARCH to 4096 to make
the search more aggressively for a possible better victim. Since
it also applies to victim selection for SSR, it will likely improve
the SSR efficiency as well.

The test case is simple. It creates as many files until the disk full.
The size for each file is 32KB. Then it writes as many as 100000
records of 4KB size to random offsets of random files in sync mode.
The testing was done on a 2GB partition of a SDHC card. Let's see the
test result of f2fs without and with the patch.

---------------------------------------
2GB partition, SDHC
create 52023 files of size 32768 bytes
random re-write 100000 records of 4KB
---------------------------------------
| file creation (s) | rewrite time (s) | gc count | gc garbage blocks |
[no patch]  341         4227             1174          174840
[patched]   324         2958             645           106682

It's obvious that, with the patch, f2fs finishes the test in 20+% less
time than without the patch. And internally it does much less gc with
higher efficiency than before.

Since the performance improvement is related to gc, it might not be so
obvious for other tests that do not trigger gc as often as this one (
This is because f2fs selects dirty segments for SSR use most of the
time when free space is in shortage). The well-known iozone test tool
was not used for benchmarking the patch becuase it seems do not have
a test case that performs random re-write on a full disk.

This patch is the revised version based on the suggestion from
Jaegeuk Kim.

Signed-off-by: Jin Xu <jinuxstyle@gmail.com>
[Jaegeuk Kim: suggested simpler solution]
Reviewed-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-05 13:50:32 +09:00
..
acl.c f2fs: support xattr security labels 2013-06-11 16:01:03 +09:00
acl.h
checkpoint.c f2fs: introduce cur_cp_version function to reduce code size 2013-08-09 15:25:37 +09:00
data.c f2fs: reserve the xattr space dynamically 2013-08-26 20:15:01 +09:00
debug.c f2fs: use seq_puts()/seq_putc() rather than seq_printf() where possible 2013-07-30 15:17:03 +09:00
dir.c f2fs: fix handling orphan inodes 2013-07-30 15:17:03 +09:00
f2fs.h f2fs: support the inline xattrs 2013-08-26 20:15:23 +09:00
file.c f2fs: reserve the xattr space dynamically 2013-08-26 20:15:01 +09:00
gc.c f2fs: optimize gc for better performance 2013-09-05 13:50:32 +09:00
gc.h f2fs: optimize gc for better performance 2013-09-05 13:50:32 +09:00
hash.c
inode.c f2fs: add flags for inline xattrs 2013-08-26 20:02:12 +09:00
Kconfig f2fs: support xattr security labels 2013-06-11 16:01:03 +09:00
Makefile
namei.c f2fs: use strncasecmp() simplify the string comparison 2013-08-27 21:50:12 +09:00
node.c f2fs: merge more bios of node block writes 2013-09-05 10:17:19 +09:00
node.h f2fs: fix the use of XATTR_NODE_OFFSET 2013-08-09 14:57:56 +09:00
recovery.c f2fs: reserve the xattr space dynamically 2013-08-26 20:15:01 +09:00
segment.c f2fs: fix a compound statement label error 2013-08-19 11:51:08 +09:00
segment.h f2fs: optimize gc for better performance 2013-09-05 13:50:32 +09:00
super.c f2fs: reserve the xattr space dynamically 2013-08-26 20:15:01 +09:00
xattr.c f2fs: support the inline xattrs 2013-08-26 20:15:23 +09:00
xattr.h f2fs: support the inline xattrs 2013-08-26 20:15:23 +09:00