I am using an I/O benchmark for measuring the I/O performance on a system. The benchmark writes a file to disk using various i/o primitives (writes, pwrite, mmap, etc.) and reports the performance. The documentation of this benchmark states that to avoid unrealistic results seen due to effects of caching, one should write a file that is atleast equal to the size of main memory on a system.
My question is, if you use fsync in your program, shouldn’t it circumvent effects of caching as it flushes unwritten i/o buffers to disk? I am asking this because our system has 64GB main memory and writing 64GB files every time for our experiments takes a long time. If I could write a smaller file like 4G or 8G, the tests would go faster.
I used fsync in a sample program and verified that caching effects are generally not seen when fsync is used, but I am curious to know what people have to say, and why the benchmark writers did not do the same.
Thanks in advance.
You are correct;
fsync()(or evenfdatasync()) shouldn’t return until the data has been written out to disk.The benchmark you describe does not sound particularly sophisticated.