Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have code that writes to a specified file and after each line (around 300 bytes) is written it calls fsync() on the file to force the changes to disk. The file in question is fairly small, under 10MB. On some servers the program takes about 1 second to run with it writing about 1200 lines. On other systems though it takes around 70 seconds. If I take out the fsync at the end of each write then the program runs in under a second on all systems. All the servers are only a couple years old and are mostly idle. They are all different model Compaq/HP servers with various 2.4 kernel revisions (RedHat 7.3).
I assume there must be some configuration parameter somewhere on the servers that is different and causing the long delays since its the same program on all the boxes. Anyone have any suggestions where to look? Or any other theories to the cause of the time difference?
I'm pretty sure the size of the file is irrelevant, I modified my test program to rewrite the same line of the file over and over (so file was only 317 bytes big) and it took the same amount of time.
Here is my test program that times creating the file with and without fsync():