Closed hwleong closed 1 year ago
Thanks for the report and the timing info, @hwleong .
The slowdown happens because sync()
flushes buffered data from cache for all files on all file systems. From man 2 sync
:
sync() causes all pending modifications to filesystem metadata and cached file data to be written to the underlying filesystems.
With a full buffer cache, this could take a long time, especially if data needs to be flushed to slow file systems.
Calling sync()
here is probably overkill. When using dsync
, we really just need to flush data for any files that it copies or at least we could limit things to the destination file system(s).
There are a couple reasons why it may have been added. When copying many files, a single call to sync
may be faster than calling fsync
individually for each file. A second reason sync
may be used is due to an old problem with Lustre, based on this commit: https://github.com/hpc/mpifileutils/commit/d1ebddb0707b269aa9d51259101175d39d837f90
As a future fix, we'd need to investigate whether sync
can be avoided altogether, and remove it if it is not needed. Another option would be to define a command-line option to let a user disable the calls to sync
.
For now, we don't have any way to disable the sync
call. As a short term workaround, you could comment out those calls and rebuild.
I noticed that when memory buff/cache is high (as seen in "free" command output), the sync() process took a long time. This can be seen in
mfu_sync_all("Syncing data to disk.")
as well asmfu_sync_all("Syncing directory updates to disk.")
. This happens even in situation where there is zero file copied using dsync. See an example below:To mitigate this issue, I ended up have to manually trigger
sync; echo 3 > /proc/sys/vm/drop_caches
to clear the cache, and the sync() will complete very quickly, just few seconds even for over a million of files. Of course, I have to become root to do this, which is not generally available for a standard normal user.Is this a known issue, or there is some tuning that can be applied?