compressor: log lvl #408

* save

* save
This commit is contained in:
Alex Sharov 2022-04-01 10:44:30 +07:00 committed by GitHub
parent 6ff6c39d13
commit 8b03582558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 14 deletions

View File

@ -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
}

View File

@ -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
}

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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
}

View File

@ -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
}

View File

@ -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})