Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloader: log alloc/sys #3162

Merged
merged 2 commits into from
Dec 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
more info
  • Loading branch information
AskAlexSharov committed Dec 24, 2021
commit db5e94204a128b407fd5ebb6bb7459a233e0b2ee
12 changes: 10 additions & 2 deletions cmd/downloader/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"path/filepath"
"runtime"
"sync"
"time"

Expand All @@ -14,6 +15,7 @@ import (
"github.com/anacrolix/torrent/storage"
"github.com/dustin/go-humanize"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/turbo/snapshotsync/snapshothashes"
"github.com/ledgerwatch/log/v3"
"golang.org/x/time/rate"
Expand Down Expand Up @@ -105,7 +107,9 @@ func MainLoop(ctx context.Context, torrentClient *torrent.Client) {
interval := time.Second * 5
logEvery := time.NewTicker(interval)
defer logEvery.Stop()
var m runtime.MemStats
var stats aggStats

for {
select {
case <-ctx.Done():
Expand All @@ -129,6 +133,10 @@ func MainLoop(ctx context.Context, torrentClient *torrent.Client) {
continue
}

runtime.ReadMemStats(&m)
alloc := common.StorageSize(m.Alloc)
sys := common.StorageSize(m.Sys)

stats = calcStats(stats, interval, torrentClient)
if allComplete {
log.Info(fmt.Sprintf(
Expand All @@ -137,7 +145,7 @@ func MainLoop(ctx context.Context, torrentClient *torrent.Client) {
humanize.Bytes(uint64(stats.writeBytesPerSec)),
stats.peersCount,
stats.torrentsCount,
))
), "alloc", alloc, "sys", sys)
continue
}

Expand All @@ -148,7 +156,7 @@ func MainLoop(ctx context.Context, torrentClient *torrent.Client) {
humanize.Bytes(uint64(stats.writeBytesPerSec)),
stats.peersCount,
stats.torrentsCount,
))
), "alloc", alloc, "sys", sys)
}
}
}
Expand Down