[gmx-developers] Re: flushing files

Erik Lindahl lindahl at cbr.su.se
Wed Oct 13 09:08:32 CEST 2010


On Oct 13, 2010, at 9:02 AM, Roland Schulz wrote:

> On Wed, Oct 13, 2010 at 2:20 AM, Erik Lindahl <lindahl at cbr.su.se> wrote:
> Hi,
> On Oct 13, 2010, at 7:53 AM, Roland Schulz wrote:
>> On Wed, Oct 13, 2010 at 1:02 AM, Erik Lindahl <lindahl at cbr.su.se> wrote:
>> Hi,
>> File flushing has been a huge issue to get working properly on AFS and other systems that have an extra layer of network disk cache. We also want to make sure the files are available e.g. on the frontend node of a cluster while the simulation is still running.
>> Do we want to guarantee that it is available sooner than at each checkpoint (thus by default 15min)?
> It's not only a matter of "being available", but making sure you don't lose all that data in the disk cache layer of the node crashes and you (for some reason) disabled checkpointing.
> Well but if you disabled checkpointing than it's your own fault ;-)
> Basically, when a frame has been "written", it is reasonable for the user to expect that it is actually on disk. The default behavior should be safe, IMHO.
> I'm not sure whether the user necessarily assumes that. Their are well known cases where the behavior of the cache is exposed to the user (e.g. writing files to USB sticks). Currently GROMACS only does a fflush not a fsync after each frame. Thus, it is not guaranteed that it is immediate on the disk because it can still be in the kernel buffers. Already now, a fsync is only done after each checkpoint.

Priority 1A is that we should never write "broken" trajectory frames to disk - that has caused huge amounts of grief in the past, and can be really confusing to users.

I think that basically leaves two long-term options:

1) Make sure that each frame is properly flushed/synced
2) Buffer IO and wait until the next checkpoint time before you write the frames to disk.

If we go with #2, there are two additional (minor?) issues: First, we need to check if checkpointing is disabled or only done every 5-10h, and in that case anyway sync frames ever ~15 minutes. Second, there could be a number of systems where we run out of memory if we buffer things. Then we need to designate a buffer amount and flush files when this is full.

> The problem is that MPI-IO doesn't have this distinction. Their is only a MPI_File_sync (and no MPI_File_flush). And a sync can be *very* expensive. 

Unfortunately we absolutely need to do a full sync at regular intervals (but #2 above would work), or you risk losing weeks of results on some clusters.

>> I think the proper solution is rather to have a separate IO thread so the disk operation can take all the latency in the world without delaying the run.
>> This won't solve it for all cases. Depending on the write frequency (e.g. every 10 frames) the flushing time can take longer than computing the frames while the actually writing time (measured as the writing time with only infrequent flush) is fast enough to not cause significant overhead. In those situations the simulation would still wait on the IO thread. 
>> Also this adds additional complexity. Not all systems like oversubscribing threads as far as I know. I know that older versions of Cray had problems and I heard their are also problems with BlueGene. Thus we would need to make the IO thread functionality optional which would add yet another duplication of code (both with and without IO thread).
> The difference is that an IO thread would virtually never run though; it would instantly block waiting for the filesystem, and in the mean time the real threads would get control back?
> Yes but you can only have one IO thread per file (otherwise the synchronization becomes quite difficult). Thus if the overhead is larger than the time between writes than your are still waiting. The time for MPI_File_sync can be * extremely* long (compared to fflush). 

Sounds like (possibly optional) buffering then ;-)



Erik Lindahl   <lindahl at cbr.su.se>  Backup: <erik.lindahl at gmail.com>
Professor of Computational Structural Biology
Center for Biomembrane Research, Dept. Biochemistry & Biophysics
Stockholm University, SE-106 91 Stockholm, Sweden
Tel: +46(0)8164675  Mobile: +46(0)703844534  Fax: mail a PDF instead

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-developers/attachments/20101013/7048f2e9/attachment.html>

More information about the gromacs.org_gmx-developers mailing list