From 8b0358255829ace31ba79d961f2bc9bed5d9e8f8 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Fri, 1 Apr 2022 10:44:30 +0700 Subject: [PATCH] compressor: log lvl #408 * save * save --- cmd/hack/hack.go | 2 +- eth/stagedsync/stage_senders.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- turbo/app/snapshots.go | 2 +- turbo/snapshotsync/block_snapshots.go | 14 +++++++------- turbo/snapshotsync/block_snapshots_test.go | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cmd/hack/hack.go b/cmd/hack/hack.go index 1869e0c68..992ee5b9c 100644 --- a/cmd/hack/hack.go +++ b/cmd/hack/hack.go @@ -1422,7 +1422,7 @@ func genstate() error { } func compress1(fileName, segmentFileName string) error { - compressor, err := compress.NewCompressor(context.Background(), "", segmentFileName, "", compress.MinPatternScore, runtime.GOMAXPROCS(-1)) + compressor, err := compress.NewCompressor(context.Background(), "", segmentFileName, "", compress.MinPatternScore, runtime.GOMAXPROCS(-1), log.LvlDebug) if err != nil { return err } diff --git a/eth/stagedsync/stage_senders.go b/eth/stagedsync/stage_senders.go index f7846260e..408e79bee 100644 --- a/eth/stagedsync/stage_senders.go +++ b/eth/stagedsync/stage_senders.go @@ -412,7 +412,7 @@ func retireBlocks(s *PruneState, tx kv.RwTx, cfg SendersCfg, ctx context.Context } } - blockFrom, blockTo, ok := cfg.blockRetire.CanRetire(s.ForwardProgress) + blockFrom, blockTo, ok := snapshotsync.CanRetire(s.ForwardProgress, cfg.blockRetire.Snapshots()) if !ok { return nil } diff --git a/go.mod b/go.mod index 9956397fb..8d821bd51 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/julienschmidt/httprouter v1.3.0 github.com/kevinburke/go-bindata v3.21.0+incompatible - github.com/ledgerwatch/erigon-lib v0.0.0-20220331085123-8c89288cbc83 + github.com/ledgerwatch/erigon-lib v0.0.0-20220401025652-224f0c9dc058 github.com/ledgerwatch/log/v3 v3.4.1 github.com/ledgerwatch/secp256k1 v1.0.0 github.com/magiconair/properties v1.8.6 // indirect diff --git a/go.sum b/go.sum index 90dba76bb..5de54ac72 100644 --- a/go.sum +++ b/go.sum @@ -617,8 +617,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20220331085123-8c89288cbc83 h1:GLYBkpd+COqC6M8r1ShkZpd6wbu+gjkPr/OdCaA9gK0= -github.com/ledgerwatch/erigon-lib v0.0.0-20220331085123-8c89288cbc83/go.mod h1:tAS6tHt0c5w9NqZfFLflGjOaWOh9BDs/gduUOy2IMOc= +github.com/ledgerwatch/erigon-lib v0.0.0-20220401025652-224f0c9dc058 h1:qSNetF0outQlcltCv7/sJ0oyARRmuh4kOslODCxKmyA= +github.com/ledgerwatch/erigon-lib v0.0.0-20220401025652-224f0c9dc058/go.mod h1:tAS6tHt0c5w9NqZfFLflGjOaWOh9BDs/gduUOy2IMOc= github.com/ledgerwatch/log/v3 v3.4.1 h1:/xGwlVulXnsO9Uq+tzaExc8OWmXXHU0dnLalpbnY5Bc= github.com/ledgerwatch/log/v3 v3.4.1/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY= github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ= diff --git a/turbo/app/snapshots.go b/turbo/app/snapshots.go index 3f8618156..854094150 100644 --- a/turbo/app/snapshots.go +++ b/turbo/app/snapshots.go @@ -194,7 +194,7 @@ func doCompress(cliCtx *cli.Context) error { return fmt.Errorf("expecting .seg file path") } f := args[0] - c, err := compress.NewCompressor(ctx, "", f, "", compress.MinPatternScore, runtime.NumCPU()/2) + c, err := compress.NewCompressor(ctx, "", f, "", compress.MinPatternScore, runtime.NumCPU()/2, log.LvlInfo) if err != nil { return err } diff --git a/turbo/snapshotsync/block_snapshots.go b/turbo/snapshotsync/block_snapshots.go index 71b294c88..f65910370 100644 --- a/turbo/snapshotsync/block_snapshots.go +++ b/turbo/snapshotsync/block_snapshots.go @@ -978,8 +978,8 @@ func (br *BlockRetire) Result() *BlockRetireResult { br.result = nil return r } -func (br *BlockRetire) CanRetire(curBlockNum uint64) (blockFrom, blockTo uint64, can bool) { - blockFrom = br.snapshots.BlocksAvailable() + 1 +func CanRetire(curBlockNum uint64, snapshots *RoSnapshots) (blockFrom, blockTo uint64, can bool) { + blockFrom = snapshots.BlocksAvailable() + 1 return canRetire(blockFrom, curBlockNum-params.FullImmutabilityThreshold) } func canRetire(from, to uint64) (blockFrom, blockTo uint64, can bool) { @@ -1118,7 +1118,7 @@ func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockF chainConfig := tool.ChainConfigFromDB(db) chainID, _ := uint256.FromBig(chainConfig.ChainID) - f, err := compress.NewCompressor(ctx, "Transactions", segmentFile, tmpDir, compress.MinPatternScore, workers) + f, err := compress.NewCompressor(ctx, "Transactions", segmentFile, tmpDir, compress.MinPatternScore, workers, lvl) if err != nil { return 0, fmt.Errorf("NewCompressor: %w, %s", err, segmentFile) } @@ -1274,7 +1274,7 @@ func DumpHeaders(ctx context.Context, db kv.RoDB, segmentFilePath, tmpDir string logEvery := time.NewTicker(20 * time.Second) defer logEvery.Stop() - f, err := compress.NewCompressor(ctx, "Headers", segmentFilePath, tmpDir, compress.MinPatternScore, workers) + f, err := compress.NewCompressor(ctx, "Headers", segmentFilePath, tmpDir, compress.MinPatternScore, workers, lvl) if err != nil { return err } @@ -1335,7 +1335,7 @@ func DumpBodies(ctx context.Context, db kv.RoDB, segmentFilePath, tmpDir string, logEvery := time.NewTicker(20 * time.Second) defer logEvery.Stop() - f, err := compress.NewCompressor(ctx, "Bodies", segmentFilePath, tmpDir, compress.MinPatternScore, workers) + f, err := compress.NewCompressor(ctx, "Bodies", segmentFilePath, tmpDir, compress.MinPatternScore, workers, lvl) if err != nil { return err } @@ -1951,7 +1951,7 @@ func (m *Merger) Merge(ctx context.Context, snapshots *RoSnapshots, mergeRanges } func (m *Merger) merge(ctx context.Context, toMerge []string, targetFile string, logEvery *time.Ticker) error { - f, err := compress.NewCompressor(ctx, "merge", targetFile, m.tmpDir, compress.MinPatternScore, m.workers) + f, err := compress.NewCompressor(ctx, "merge", targetFile, m.tmpDir, compress.MinPatternScore, m.workers, m.lvl) if err != nil { return err } @@ -2054,7 +2054,7 @@ func cpSegmentByWords(ctx context.Context, srcF, dstF, tmpDir string) error { return err } defer d.Close() - out, err := compress.NewCompressor(ctx, "", dstF, tmpDir, compress.MinPatternScore, workers) + out, err := compress.NewCompressor(ctx, "", dstF, tmpDir, compress.MinPatternScore, workers, log.LvlDebug) if err != nil { return err } diff --git a/turbo/snapshotsync/block_snapshots_test.go b/turbo/snapshotsync/block_snapshots_test.go index f8efdbe82..4890d0721 100644 --- a/turbo/snapshotsync/block_snapshots_test.go +++ b/turbo/snapshotsync/block_snapshots_test.go @@ -20,7 +20,7 @@ import ( ) func createTestSegmentFile(t *testing.T, from, to uint64, name Type, dir string) { - c, err := compress.NewCompressor(context.Background(), "test", filepath.Join(dir, SegmentFileName(from, to, name)), dir, 100, 1) + c, err := compress.NewCompressor(context.Background(), "test", filepath.Join(dir, SegmentFileName(from, to, name)), dir, 100, 1, log.LvlDebug) require.NoError(t, err) defer c.Close() err = c.AddWord([]byte{1})