wince的diskcache和filecache

wince系统中存在diskcache和filecache两种cache,通俗的来讲diskcache是与块设备存取访问相关的,对应的是在注册表设置如下内容
; global setting
[HKEY_LOCAL_MACHINE\System\StorageManager\FATFS]
  "EnableCache"=dword:0
  "FatCacheSize"=dword:200
  "DataCacheSize"=dword:400

; only for nandflash
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\MSFlash\FATFS]
  "FatCacheSize"=dword:200
  "DataCacheSize"=dword:400
而filecache是与文件访问相关的,对应的系统添加cachefilt组件,或是在config.bib设置pagepool相关内容
kernel.dll:LoaderPoolTarget       00000000  01000000  FIXUPVAR ;Paging Pool Target Size
kernel.dll:LoaderPoolMaximum      00000000  02000000  FIXUPVAR ;Paging Pool Maximum Size
关于两者的区别和联系可以从下文中得到解答
"EnableCache"=dword:0 Is the more cleaner way to do it. 

About the page pool and windows cache (actualy disk caching): They both store data in the memory for fast retrieval.

But the "windows cache" only stores data for fast retrieval and buffer a write to disk. This cache is a copy from the original data. When data is needed it will be copied from the cache to where it is needed.

The page pool can only store read only data, but if a program is loaded in to memory (for example you start Opera), the read only parts are loaded in to the page pool (data/code), not a chunk of additional memory.
The program is then executed using the memory of the page pool.

So it's possible to start 3 programs and not to see your memory usage going up because those programs are using memory from the page pool.

After you close a program, the memory it uses from the page pool is not released, but it's free for an other program to use (overwrite), or when you start that same program again, it doesn't have to load itself from disk again since the data/code is already there in the page pool.

Thats why a to small page pool give worse performance.

在实际使用当中,对于diskcache,进行sd卡读写测试的时候,写到一定数量的数据WriteFile会明显停顿一会,这个时候应该就是在进行writeback动作了,如果在CreateFile的时候指定FILE_FLAG_NO_BUFFERING则无此明显停顿现象,而且整体速度要快一些;对于filecache,当exe很大(达到10MB以上),如果不设置config.bib,每次加载的时候要么是很慢,要么会易出现莫名其妙的异常。

补充:
在另外一台机器上测试sd卡的写速度时,发现加没加FILE_FLAG_NO_BUFFERING速度都差不多,也没有出现停顿现象,经过比较发现是因为系统没添加cachefilt组件,由此推测:
1、cachefilt是fsd(ce6才有cachefilt,其fsd是exfat.dll)的上层建筑,它完成filecache工作,filecache主要用于提高文件操作IO性能(应该主要是访问速度)。当无cachefilt组件时FILE_FLAG_NO_BUFFERING是无效的。
2、fsd完成diskcache工作,diskcache主要用于解决文件IO速度慢于fsd操作的问题(通过缓存设备数据来降低访问次数),如果要降低数据丢失概率则需要使用FILE_FLAG_WRITE_THROUGH标志(提高了设备访问次数可能会降低使用寿命)

关于这两点猜测在引用三中得到证实,要点内容列举如下:

Even without file cache and disk cache, it doesn't imply the data will be written to storage directly.
Unless you specific Write Through mode when open the file (CreateFile), some of the data may still in the file system or storage driver's internal write buffer.

不过它还提到了第三种cache,这个是filesystem和block driver用于存取设备的cache(例如,fat32中最多一次传送的是64扇区),要点内容如下:
Unlike cache, the write buffer of File system or Storage driver just like it name, a  buffer between under layer IO and the software.

Because the block device driver (Storage) or the File System storage (e.g. a FAT cluster) need to be accessed via a basic unit (sector/cluster); the purpose of write buffer is to have a temporally memory for this basic unit so upper layer software does not need to access data aligned to the basic unit size.

When you using WriteFile API, you can write whatever size you want, so it is possible some of the data may not drain to the storage but still in the write buffer. With FILE_FLAG_WRITE_THROUGH flag, it indicates file system and block driver to drain the write buffer on each accessing.

 

相关引用:
1、http://bbs.csdn.net/topics/330174610
2、http://forum.xda-developers.com/showthread.php?t=530710&page=91
3、https://social.msdn.microsoft.com/Forums/en-US/c4c10464-6da4-45e4-8a57-7e87eedff1d0/windows-ce-60-exfat-file-system?forum=winembplatdev





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值