Method 1
-----------------------------------------
CreateFile(...)
for (cnt=0; cnt!=TEST_CNT; cnt++)
{
start = GetTickCount();
SetFilePointer(hFileInput, 0, 0, FILE_BEGIN);
loop ReadFile(..., buf, bufSize, ...) through the file
end = GetTickCount();
Dump (end - start);
}
Method 2
-----------------------------------------
CreateFile(...);
dwFileSize = GetFileSize(...);
CreateFileMapping(...);
pFile = MapViewOfFile(...);
for (cnt=0; cnt!=TEST_CNT; cnt++)
{
start = GetTickCount();
loop memcpy(buf, pFile + offset, bufSize) through the whole
file ;
end = GetTickCount();
Dump (end - start);
}
I use a 5MB test file and a 1MB buf to do the test on ATA and
calculate the read performace in MBps (with file cache pool big
enough). I set SYSGEN_CACHEFILT = 0 for these tests.
For method 1 (ReadFile Method)
the first time has a performance of 10.7MBps
after that each time has a performance of about 13.7MBps.
For method 2 (MemoryMapFile Method)
the first time has a performance of 1.3MBps
after that each time has a performance of about 253.9MBps
Obviously, with method 2, after the first time the file is read
through, all the file data are cached in file cache, after that all
access to the file has a dramatically fast speed. However, the
drawback is that the first time access performance compared to method
1 also dropped quite a lot, about 1/8 of the original speed.
It is quite beyond imagination that the first time performance using
memory map method deteriorate so much, even unacceptable.
I also set SYSGEN_CACHEFILT=1 to do the test, per my understanding of
CE6 file cache manager, setting this will make ReadFile method to do
similar thing like MemoryMap method. However the result don't make
much difference.
So I have the following 2 questions
1. What is the cause of MemoryMap method first time performance
deterioration?
2. Is it possible to make ReadFile method behave similar to
MemoryMapFile method? (i.e. default cache file content to file buffer
pool.)
Anyone give me some hint?