Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Log time to do fs sync on layer create (#349)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lasse-damgaard committed Nov 4, 2020
1 parent 239e1f2 commit 7d88e9f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/snapshot/mem_fs.go
Expand Up @@ -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() {
Expand All @@ -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
Expand Down

0 comments on commit 7d88e9f

Please sign in to comment.