better logs
This commit is contained in:
parent
8c8fb2f9f0
commit
c623b256a3
|
|
@ -491,6 +491,8 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *regis
|
|||
}
|
||||
|
||||
// Log progress periodically
|
||||
// Page cache warning: if spread > 1GB, hasher may hit disk instead of RAM
|
||||
const pageCacheWarningBytes = 1 << 30 // 1GB
|
||||
progressDone := make(chan struct{})
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
|
|
@ -498,9 +500,18 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *regis
|
|||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
dl := int(b.Completed.Load() * 100 / b.Total)
|
||||
h := int(sh.Hashed() * 100 / b.Total)
|
||||
slog.Info(fmt.Sprintf("progress: downloaded %d%% | hashed %d%%", dl, h))
|
||||
downloaded := b.Completed.Load()
|
||||
hashed := sh.Hashed()
|
||||
dlPct := int(downloaded * 100 / b.Total)
|
||||
hPct := int(hashed * 100 / b.Total)
|
||||
spread := dlPct - hPct
|
||||
spreadBytes := downloaded - hashed
|
||||
|
||||
msg := fmt.Sprintf("progress: downloaded %d%% | hashed %d%% | spread %d%%", dlPct, hPct, spread)
|
||||
if spreadBytes > pageCacheWarningBytes {
|
||||
msg += fmt.Sprintf(" [WARNING: %.1fGB ahead, page cache pressure]", float64(spreadBytes)/(1<<30))
|
||||
}
|
||||
slog.Info(msg)
|
||||
case <-progressDone:
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue