From f9a05717a0c90289d6983dd222259ddb6e36ed2e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:51:28 +0000 Subject: [PATCH] Update module github.com/vbauerster/mpb/v8 to v8.7.2 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 +-- vendor/github.com/vbauerster/mpb/v8/bar.go | 3 -- .../github.com/vbauerster/mpb/v8/decor/eta.go | 19 +++++++---- .../vbauerster/mpb/v8/decor/speed.go | 32 +++++++++++-------- .../github.com/vbauerster/mpb/v8/progress.go | 11 ++++--- vendor/modules.txt | 2 +- 7 files changed, 43 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index 2f59b2b279..b83f7e5003 100644 --- a/go.mod +++ b/go.mod @@ -62,7 +62,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 github.com/ulikunitz/xz v0.5.11 - github.com/vbauerster/mpb/v8 v8.7.1 + github.com/vbauerster/mpb/v8 v8.7.2 github.com/vishvananda/netlink v1.2.1-beta.2 go.etcd.io/bbolt v1.3.8 golang.org/x/exp v0.0.0-20231006140011-7918f672742d diff --git a/go.sum b/go.sum index 5269476bab..95f5bf8858 100644 --- a/go.sum +++ b/go.sum @@ -1073,8 +1073,8 @@ github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI= github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts= github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= -github.com/vbauerster/mpb/v8 v8.7.1 h1:bQoSMMTFAg/gjsLrBYmO8gbRcZt7aDq6WI2IMa9BTqM= -github.com/vbauerster/mpb/v8 v8.7.1/go.mod h1:fWgXcAu4W+0cBSUh4ZlaKJyC2KtgU27ZSTaiIk0QNsQ= +github.com/vbauerster/mpb/v8 v8.7.2 h1:SMJtxhNho1MV3OuFgS1DAzhANN1Ejc5Ct+0iSaIkB14= +github.com/vbauerster/mpb/v8 v8.7.2/go.mod h1:ZFnrjzspgDHoxYLGvxIruiNk73GNTPG4YHgVNpR10VY= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= diff --git a/vendor/github.com/vbauerster/mpb/v8/bar.go b/vendor/github.com/vbauerster/mpb/v8/bar.go index 390bc36a34..bca7982986 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar.go @@ -305,9 +305,6 @@ func (b *Bar) EwmaIncrBy(n int, iterDur time.Duration) { // EwmaIncrInt64 increments progress by amount of n and updates EWMA based // decorators by dur of a single iteration. func (b *Bar) EwmaIncrInt64(n int64, iterDur time.Duration) { - if n <= 0 { - return - } select { case b.operateState <- func(s *bState) { s.decoratorEwmaUpdate(n, iterDur) diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/eta.go b/vendor/github.com/vbauerster/mpb/v8/decor/eta.go index ecb6f8f926..ecf87b1865 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/eta.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/eta.go @@ -54,18 +54,19 @@ func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator { func MovingAverageETA(style TimeStyle, average ewma.MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator { d := &movingAverageETA{ WC: initWC(wcc...), + producer: chooseTimeProducer(style), average: average, normalizer: normalizer, - producer: chooseTimeProducer(style), } return d } type movingAverageETA struct { WC + producer func(time.Duration) string average ewma.MovingAverage normalizer TimeNormalizer - producer func(time.Duration) string + zDur time.Duration } func (d *movingAverageETA) Decor(s Statistics) (string, int) { @@ -78,11 +79,17 @@ func (d *movingAverageETA) Decor(s Statistics) (string, int) { } func (d *movingAverageETA) EwmaUpdate(n int64, dur time.Duration) { - durPerItem := float64(dur) / float64(n) - if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) { - return + if n <= 0 { + d.zDur += dur + } else { + durPerItem := float64(d.zDur+dur) / float64(n) + if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) { + d.zDur += dur + return + } + d.zDur = 0 + d.average.Add(durPerItem) } - d.average.Add(durPerItem) } // AverageETA decorator. It's wrapper of NewAverageETA. diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/speed.go b/vendor/github.com/vbauerster/mpb/v8/decor/speed.go index 5879d06042..f3355c4255 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/speed.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/speed.go @@ -69,8 +69,8 @@ func EwmaSpeed(unit interface{}, format string, age float64, wcc ...WC) Decorato func MovingAverageSpeed(unit interface{}, format string, average ewma.MovingAverage, wcc ...WC) Decorator { d := &movingAverageSpeed{ WC: initWC(wcc...), - average: average, producer: chooseSpeedProducer(unit, format), + average: average, } return d } @@ -79,26 +79,32 @@ type movingAverageSpeed struct { WC producer func(float64) string average ewma.MovingAverage - msg string + zDur time.Duration } func (d *movingAverageSpeed) Decor(s Statistics) (string, int) { - if !s.Completed { - var speed float64 - if v := d.average.Value(); v > 0 { - speed = 1 / v - } - d.msg = d.producer(speed * 1e9) + var str string + // ewma implementation may return 0 before accumulating certain number of samples + if v := d.average.Value(); v != 0 { + str = d.producer(1e9 / v) + } else { + str = d.producer(0) } - return d.Format(d.msg) + return d.Format(str) } func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) { - durPerByte := float64(dur) / float64(n) - if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) { - return + if n <= 0 { + d.zDur += dur + } else { + durPerByte := float64(d.zDur+dur) / float64(n) + if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) { + d.zDur += dur + return + } + d.zDur = 0 + d.average.Add(durPerByte) } - d.average.Add(durPerByte) } // AverageSpeed decorator with dynamic unit measure adjustment. It's diff --git a/vendor/github.com/vbauerster/mpb/v8/progress.go b/vendor/github.com/vbauerster/mpb/v8/progress.go index 0bd17bfbc9..3bdc75b423 100644 --- a/vendor/github.com/vbauerster/mpb/v8/progress.go +++ b/vendor/github.com/vbauerster/mpb/v8/progress.go @@ -68,8 +68,6 @@ func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress { ctx = context.Background() } ctx, cancel := context.WithCancel(ctx) - delayRC := make(chan struct{}, 1) - delayRC <- struct{}{} s := &pState{ ctx: ctx, hm: make(heapManager), @@ -78,7 +76,6 @@ func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress { renderReq: make(chan time.Time), popPriority: math.MinInt32, refreshRate: defaultRefreshRate, - delayRC: delayRC, queueBars: make(map[*Bar]*Bar), output: os.Stdout, debugOut: io.Discard, @@ -262,11 +259,17 @@ func (p *Progress) Shutdown() { func (p *Progress) serve(s *pState, cw *cwriter.Writer) { defer p.pwg.Done() var err error - w := cwriter.New(io.Discard) + var w *cwriter.Writer renderReq := s.renderReq operateState := p.operateState interceptIO := p.interceptIO + if s.delayRC != nil { + w = cwriter.New(io.Discard) + } else { + w, cw = cw, nil + } + for { select { case <-s.delayRC: diff --git a/vendor/modules.txt b/vendor/modules.txt index 99dfd17d3e..9c7b1393a6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1058,7 +1058,7 @@ github.com/ulikunitz/xz/lzma github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/storage -# github.com/vbauerster/mpb/v8 v8.7.1 +# github.com/vbauerster/mpb/v8 v8.7.2 ## explicit; go 1.17 github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8/cwriter