Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion chain/actors/adt/diff/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"bytes"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lily/chain/actors/adt"
logging "github.com/ipfs/go-log/v2"
typegen "github.com/whyrusleeping/cbor-gen"

"github.com/filecoin-project/lily/chain/actors/adt"
)

var log = logging.Logger("lily/chain/diff")

// ArrayDiffer generalizes adt.Array diffing by accepting a Deferred type that can unmarshalled to its corresponding struct
// in an interface implantation.
// Add should be called when a new k,v is added to the array
Expand Down
20 changes: 19 additions & 1 deletion chain/actors/adt/diff/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package diff

import (
"context"
"os"
"runtime"
"strconv"

"github.com/filecoin-project/go-hamt-ipld/v3"
"github.com/filecoin-project/lotus/chain/actors/adt"
Expand All @@ -10,6 +13,21 @@ import (
adt2 "github.com/filecoin-project/lily/chain/actors/adt"
)

var HamtParallelWorkerLimit int64

const HamtParallelWorkerEnv = "LILY_HAMT_PARALLEL_WORKER_LIMIT"

func init() {
HamtParallelWorkerLimit = int64(runtime.NumCPU())
workerStr := os.Getenv(HamtParallelWorkerEnv)
if workerStr != "" {
HamtParallelWorkerLimit, err := strconv.ParseInt(workerStr, 10, 64)
if err != nil {
log.Warnf("failed to parse env %s defaulting to %d (runtime.NumCPU()) : %s", HamtParallelWorkerEnv, HamtParallelWorkerLimit, err)
}
}
}

// Hamt returns a set of changes that transform `preMap` into `curMap`. opts are applied to both `preMap` and `curMap`.
func Hamt(ctx context.Context, preMap, curMap adt2.Map, preStore, curStore adt.Store, hamtOpts ...hamt.Option) ([]*hamt.Change, error) {
ctx, span := otel.Tracer("").Start(ctx, "Hamt.Diff")
Expand All @@ -25,5 +43,5 @@ func Hamt(ctx context.Context, preMap, curMap adt2.Map, preStore, curStore adt.S
return nil, err
}

return hamt.Diff(ctx, preStore, curStore, preRoot, curRoot, hamtOpts...)
return hamt.ParallelDiff(ctx, preStore, curStore, preRoot, curRoot, HamtParallelWorkerLimit, hamtOpts...)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349 // indirect
github.com/filecoin-project/go-amt-ipld/v3 v3.1.1
github.com/filecoin-project/go-bitfield v0.2.4
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.1-0.20220505191157-d7766f8628ec
github.com/filecoin-project/go-jsonrpc v0.1.5
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.1.3
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CW
github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM=
github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0/go.mod h1:7aWZdaQ1b16BVoQUYR+eEvrDCGJoPLxFpDynFjYfBjI=
github.com/filecoin-project/go-hamt-ipld/v3 v3.0.1/go.mod h1:gXpNmr3oQx8l3o7qkGyDjJjYSRX7hp/FGOStdqrWyDI=
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0 h1:rVVNq0x6RGQIzCo1iiJlGFm9AGIZzeifggxtKMU7zmI=
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBwFmYdT8SOFUwB3ovSUfG1Ux0g=
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.1-0.20220505191157-d7766f8628ec h1:v+qI303NEoIxZMAsK6Ry4twUm4fFdDilY6x7RJRFdJo=
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.1-0.20220505191157-d7766f8628ec/go.mod h1:LNNMpJFvDONV8ZMjKAgwjpYMQiINukJHshJJBgeBt3M=
github.com/filecoin-project/go-indexer-core v0.2.8/go.mod h1:IagNfTdFuX4057kla43PjRCn3yBuUiZgIxuA0hTUamY=
github.com/filecoin-project/go-jsonrpc v0.1.5 h1:ckxqZ09ivBAVf5CSmxxrqqNHC7PJm3GYGtYKiNQ+vGk=
github.com/filecoin-project/go-jsonrpc v0.1.5/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4=
Expand Down