From 7d88e9f92502fd18aadf877681d23cd1e46ef3ed Mon Sep 17 00:00:00 2001 From: lasse Date: Wed, 4 Nov 2020 11:39:39 +0100 Subject: [PATCH] Log time to do fs sync on layer create (#349) In our usage we are seeing occasional very large gaps between the final node in the build running and the subsequent layer commit. We suspect that fs sync before the layer diff is calculated is the cause and would like to get confirmation on this. --- lib/snapshot/mem_fs.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/snapshot/mem_fs.go b/lib/snapshot/mem_fs.go index 0b95b602..49144863 100644 --- a/lib/snapshot/mem_fs.go +++ b/lib/snapshot/mem_fs.go @@ -292,6 +292,8 @@ func (fs *MemFS) AddLayerByCopyOps(cs []*CopyOperation, w *tar.Writer) error { // It also waits at least one sec, in case mtime doesn't have sub-second // resolution. func (fs *MemFS) sync() { + start := time.Now() + // Ensure this function takes at least one sec. block := make(chan interface{}, 1) go func() { @@ -303,6 +305,9 @@ func (fs *MemFS) sync() { syscall.Sync() <-block + + duration := time.Since(start).Round(time.Millisecond) + log.Infow("* Synchronized file system", "duration", duration) } // createLayerByScan computes the differences between the file system and merged