Re: [PATCH] f2fs: sepearte hot/cold in free nid

From: Chao Yu
Date: Fri Apr 20 2018 - 05:46:25 EST


On 2018/4/20 12:04, Chao Yu wrote:
> On 2018/4/20 11:37, Jaegeuk Kim wrote:
>> On 04/20, Chao Yu wrote:
>>> As most indirect node, dindirect node, and xattr node won't be updated
>>> after they are created, but inode node and other direct node will change
>>> more frequently, so store their nat entries mixedly in whole nat table
>>> will suffer:
>>> - fragment nat table soon due to different update rate
>>> - more nat block update due to fragmented nat table
>>>
>>> In order to solve above issue, we're trying to separate whole nat table to
>>> two part:
>>> a. Hot free nid area:
>>> - range: [nid #0, nid #x)
>>> - store node block address for
>>> * inode node
>>> * other direct node
>>> b. Cold free nid area:
>>> - range: [nid #x, max nid)
>>> - store node block address for
>>> * indirect node
>>> * dindirect node
>>> * xattr node
>>>
>>> Allocation strategy example:
>>>
>>> Free nid: '-'
>>> Used nid: '='
>>>
>>> 1. Initial status:
>>> Free Nids: |-----------------------------------------------------------------------|
>>> ^ ^ ^ ^
>>> Alloc Range: |---------------| |---------------|
>>> hot_start hot_end cold_start cold_end
>>>
>>> 2. Free nids have ran out:
>>> Free Nids: |===============-----------------------------------------===============|
>>> ^ ^ ^ ^
>>> Alloc Range: |===============| |===============|
>>> hot_start hot_end cold_start cold_end
>>>
>>> 3. Expand hot/cold area range:
>>> Free Nids: |===============-----------------------------------------===============|
>>> ^ ^ ^ ^
>>> Alloc Range: |===============----------------| |----------------===============|
>>> hot_start hot_end cold_start cold_end
>>>
>>> 4. Hot free nids have ran out:
>>> Free Nids: |===============================-------------------------===============|
>>> ^ ^ ^ ^
>>> Alloc Range: |===============================| |----------------===============|
>>> hot_start hot_end cold_start cold_end
>>>
>>> 5. Expand hot area range, hot/cold area boundary has been fixed:
>>> Free Nids: |===============================-------------------------===============|
>>> ^ ^ ^
>>> Alloc Range: |===============================--------|----------------===============|
>>> hot_start hot_end(cold_start) cold_end
>>>
>>> Run xfstests with generic/*:
>>>
>>> before
>>> node_write: 169660
>>> cp_count: 60118
>>> node/cp 2.82
>>>
>>> after:
>>> node_write: 159145
>>> cp_count: 84501
>>> node/cp: 2.64
>>
>> Nice trial tho, I don't see much benefit on this huge patch. I guess we may be
>> able to find an efficient way to achieve this issue rather than changing whole
>> stable codes.
>
> IMO, based on this, later, we can add more allocation policy to manage free nid
> resource to get more benefit.
>
> If you worry about code stability, we can queue this patch in dev-test branch to
> test this longer time.
>
>>
>> How about getting a free nid in the list from head or tail separately?
>
> I don't think this can get benefit from long time used image, since nat table
> will be fragmented anyway, then we won't know free nid in head or in tail comes
> from hot nat block or cold nat block.
>
> Anyway, I will have a try.

A quick test result with below patch:

node_write:187837, cp_count:76431