From fd5edd5df35fe589277c831b9687b56afe052bfa Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Tue, 11 Aug 2015 13:47:08 -0700 Subject: [PATCH] Avoid buffering to tempfile when pushing with V2 The practice of buffering to a tempfile during a pushing contributes massively to slow V2 push performance perception. The protocol was actually designed to avoid precalculation, supporting cut-through data push. This means we can assemble the layer, calculate its digest and push to the remote endpoint, all at the same time. This should increase performance massively on systems with slow disks or IO bottlenecks. Signed-off-by: Stephen J Day --- jsonmessage/jsonmessage.go | 6 ++++++ jsonmessage/jsonmessage_test.go | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jsonmessage/jsonmessage.go b/jsonmessage/jsonmessage.go index f3bcc8e..f12547c 100644 --- a/jsonmessage/jsonmessage.go +++ b/jsonmessage/jsonmessage.go @@ -67,8 +67,14 @@ func (p *JSONProgress) String() string { } pbBox = fmt.Sprintf("[%s>%s] ", strings.Repeat("=", percentage), strings.Repeat(" ", numSpaces)) } + numbersBox = fmt.Sprintf("%8v/%v", current, total) + if p.Current > p.Total { + // remove total display if the reported current is wonky. + numbersBox = fmt.Sprintf("%8v", current) + } + if p.Current > 0 && p.Start > 0 && percentage < 50 { fromStart := time.Now().UTC().Sub(time.Unix(p.Start, 0)) perEntry := fromStart / time.Duration(p.Current) diff --git a/jsonmessage/jsonmessage_test.go b/jsonmessage/jsonmessage_test.go index 2e78fa7..889b0ba 100644 --- a/jsonmessage/jsonmessage_test.go +++ b/jsonmessage/jsonmessage_test.go @@ -3,12 +3,12 @@ package jsonmessage import ( "bytes" "fmt" + "strings" "testing" "time" "github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/timeutils" - "strings" ) func TestError(t *testing.T) { @@ -45,7 +45,7 @@ func TestProgress(t *testing.T) { } // this number can't be negative gh#7136 - expected = "[==================================================>] 50 B/40 B" + expected = "[==================================================>] 50 B" jp5 := JSONProgress{Current: 50, Total: 40} if jp5.String() != expected { t.Fatalf("Expected %q, got %q", expected, jp5.String())