Writing NAND too slowly due to unnecessary block recover

185 views
Skip to first unread message

Zhang Jianjun

unread,
Oct 23, 2015, 10:12:51 PM10/23/15
to UFFS
Test environment: 
CPU: STM32F407, 168MHZ
NAND:  Page size: 4096
             Page num per block: 128
Operation: File is sequentially wroten to nand, with file size around 4M bytes.
Speed: less than 200k bytes/s
Cause: A block recover occurs every time data cross block boundary, slow down the write speed. In 
sequential writing, block recover is not necessary.
文件是顺序写的,每当跨block时,都会将block复制一份,导致写得很慢。其实在这种情况没必须执行recover。

code cause problem:
URET _BufFlush(struct uffs_DeviceSt *dev,   UBOOL force_block_recover, int slot)
{
.....
    n = uffs_GetFreePagesCount(dev, bc);

    if (n >= dev->buf.dirtyGroup[slot].count && !force_block_recover) {
        //The free pages are enough for the dirty pages
        ret = uffs_BufFlush_Exist_With_Enough_FreePage(dev,    slot, node, bc);
    }
    else {
        ret = uffs_BufFlush_Exist_With_BlockRecover(dev, slot, node, bc, U_FALSE);
    }
.....
}

Zhang Jianjun

unread,
Oct 24, 2015, 9:34:58 PM10/24/15
to UFFS
43 block recover are called when sequentially writing file with 8 block, why? 
related config: 
#define MAX_PAGE_BUFFERS 8
#define CLONE_BUFFERS_THRESHOLD 1
#define MAX_DIRTY_PAGES_IN_A_BLOCK 3

在 2015年10月24日星期六 UTC+8上午10:12:51,Zhang Jianjun写道:

Zhang Jianjun

unread,
Nov 5, 2015, 11:09:29 PM11/5/15
to UFFS
Page大小是4096,应用层是按4096大小写入的。实际由于mini head数据大小是4092/page,结果写8个block产生了43次block recover。应用层改成每次写入4092大小,就只有8次recover了。
这种缓存机制有问题吧?循序写的时候完全没有必要recover啊?本想自己改改,还没弄太清楚,不知道怎么改。

在 2015年10月25日星期日 UTC+8上午9:34:58,Zhang Jianjun写道:
Reply all
Reply to author
Forward
0 new messages