jeudi 9 septembre 2021

Profiling FileIOs - Is this behaviour because of Caching ? Using FILE_FLAG_NO_BUFFERING

I am working on creating a program that profiles read IOs using IOCP. I am reading my file using the following way. What I am doing is basically doing a random read. Once the read is acknowledged by a completion port using GetQueuedCompletionStatus. I do another random read and I keep doing this for a specific amount of time. I noticed that the first time I ran this application total IOs I got in 5 seconds was 700. The next time I ran this application again the totalIOs in 5 seconds was 900. The third time I ran the application the totalIOs in 5 seconds was 1200. Eventually the 7th time it was 1800. Now it seems to go back b/w 1600 to 1800. I am not sure why that is happening ? Is that because of Caching? if so I read that to disable caching you can use the FILE_FLAG_NO_BUFFERING. I am still getting this behaviour and I am curious what the reason might be ?

HANDLE getFileHandle()
{
 DWORD dwFlags = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
        
    HANDLE hFile = CreateFileA(
        pszFilename,
        (GENERIC_READ),
        (FILE_SHARE_READ),
        nullptr,
        OPEN_EXISTING,
        dwFlags, 
        nullptr);
       

    if (INVALID_HANDLE_VALUE == hFile)
    {
        //Error
        return nullptr;
    }

    return hFile;
}

I would be happy to add more detail.

Aucun commentaire:

Enregistrer un commentaire