Skip to content

Commit

Permalink
remove byte mempool (#5951)
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas committed May 22, 2020
1 parent 8eb7c7a commit 6a9112b
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 212 deletions.
1 change: 0 additions & 1 deletion beacon-chain/state/BUILD.bazel
Expand Up @@ -27,7 +27,6 @@ go_library(
"//shared/bytesutil:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/hashutil:go_default_library",
"//shared/memorypool:go_default_library",
"//shared/params:go_default_library",
"//shared/sliceutil:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
Expand Down
13 changes: 1 addition & 12 deletions beacon-chain/state/field_trie.go
Expand Up @@ -10,7 +10,6 @@ import (
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/memorypool"
)

// FieldTrie is the representation of the representative
Expand Down Expand Up @@ -109,17 +108,7 @@ func (f *FieldTrie) CopyTrie() *FieldTrie {
Mutex: new(sync.Mutex),
}
}
dstFieldTrie := [][]*[32]byte{}
switch f.field {
case randaoMixes:
dstFieldTrie = memorypool.GetRandaoMixesTrie(len(f.fieldLayers))
case blockRoots, stateRoots:
dstFieldTrie = memorypool.GetRootsTrie(len(f.fieldLayers))
case validators:
dstFieldTrie = memorypool.GetValidatorsTrie(len(f.fieldLayers))
default:
dstFieldTrie = make([][]*[32]byte, len(f.fieldLayers))
}
dstFieldTrie := make([][]*[32]byte, len(f.fieldLayers))

for i, layer := range f.fieldLayers {
if len(dstFieldTrie[i]) < len(layer) {
Expand Down
3 changes: 1 addition & 2 deletions beacon-chain/state/getters.go
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/go-bitfield"
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/memorypool"
"github.com/prysmaticlabs/prysm/shared/params"
)

Expand Down Expand Up @@ -579,7 +578,7 @@ func (b *BeaconState) RandaoMixes() [][]byte {
b.lock.RLock()
defer b.lock.RUnlock()

mixes := memorypool.GetDoubleByteSlice(len(b.state.RandaoMixes))
mixes := make([][]byte, len(b.state.RandaoMixes))
for i, r := range b.state.RandaoMixes {
tmpRt := make([]byte, len(r))
copy(tmpRt, r)
Expand Down
3 changes: 1 addition & 2 deletions beacon-chain/state/setters.go
Expand Up @@ -11,7 +11,6 @@ import (
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/memorypool"
)

// SetGenesisTime for the beacon state.
Expand Down Expand Up @@ -456,7 +455,7 @@ func (b *BeaconState) UpdateRandaoMixesAtIndex(idx uint64, val []byte) error {
mixes := b.state.RandaoMixes
if refs := b.sharedFieldReferences[randaoMixes].refs; refs > 1 {
if featureconfig.Get().EnableStateRefCopy {
mixes = memorypool.GetDoubleByteSlice(len(b.state.RandaoMixes))
mixes = make([][]byte, len(b.state.RandaoMixes))
copy(mixes, b.state.RandaoMixes)
} else {
mixes = b.RandaoMixes()
Expand Down
13 changes: 0 additions & 13 deletions beacon-chain/state/state_trie.go
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/memorypool"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/sliceutil"
"go.opencensus.io/trace"
Expand Down Expand Up @@ -162,18 +161,6 @@ func (b *BeaconState) Copy() *BeaconState {
if b.stateFieldLeaves[field].reference != nil {
b.stateFieldLeaves[field].MinusRef()
}
if field == randaoMixes && v.refs == 0 {
memorypool.PutDoubleByteSlice(b.state.RandaoMixes)
if b.stateFieldLeaves[field].refs == 0 {
memorypool.PutRandaoMixesTrie(b.stateFieldLeaves[randaoMixes].fieldLayers)
}
}
if (field == blockRoots || field == stateRoots) && v.refs == 0 && b.stateFieldLeaves[field].refs == 0 {
memorypool.PutRootsTrie(b.stateFieldLeaves[field].fieldLayers)
}
if field == validators && v.refs == 0 && b.stateFieldLeaves[field].refs == 0 {
memorypool.PutValidatorsTrie(b.stateFieldLeaves[validators].fieldLayers)
}
}
})

Expand Down
5 changes: 0 additions & 5 deletions shared/featureconfig/config.go
Expand Up @@ -42,7 +42,6 @@ type Flags struct {
SlasherProtection bool // SlasherProtection protects validator fron sending over a slashable offense over the network using external slasher.
DisableStrictAttestationPubsubVerification bool // DisableStrictAttestationPubsubVerification will disabling strict signature verification in pubsub.
DisableUpdateHeadPerAttestation bool // DisableUpdateHeadPerAttestation will disabling update head on per attestation basis.
EnableByteMempool bool // EnaableByteMempool memory management.
EnableDomainDataCache bool // EnableDomainDataCache caches validator calls to DomainData per epoch.
EnableStateGenSigVerify bool // EnableStateGenSigVerify verifies proposer and randao signatures during state gen.
CheckHeadState bool // CheckHeadState checks the current headstate before retrieving the desired state from the db.
Expand Down Expand Up @@ -166,10 +165,6 @@ func ConfigureBeaconChain(ctx *cli.Context) {
log.Warn("Disabled update head on per attestation basis")
cfg.DisableUpdateHeadPerAttestation = true
}
if ctx.Bool(enableByteMempool.Name) {
log.Warn("Enabling experimental memory management for beacon state")
cfg.EnableByteMempool = true
}
if ctx.Bool(enableStateGenSigVerify.Name) {
log.Warn("Enabling sig verify for state gen")
cfg.EnableStateGenSigVerify = true
Expand Down
11 changes: 6 additions & 5 deletions shared/featureconfig/flags.go
Expand Up @@ -93,10 +93,6 @@ var (
Name: "disable-update-head-attestation",
Usage: "Disable update fork choice head on per attestation. See PR 4802 for details.",
}
enableByteMempool = &cli.BoolFlag{
Name: "enable-byte-mempool",
Usage: "Enable use of sync.Pool for certain byte arrays in the beacon state",
}
disableDomainDataCacheFlag = &cli.BoolFlag{
Name: "disable-domain-data-cache",
Usage: "Disable caching of domain data requests per epoch. This feature reduces the total " +
Expand Down Expand Up @@ -356,6 +352,11 @@ var (
Usage: deprecatedUsage,
Hidden: true,
}
deprecatedEnableByteMempool = &cli.BoolFlag{
Name: "enable-byte-mempool",
Usage: deprecatedUsage,
Hidden: true,
}
)

var deprecatedFlags = []cli.Flag{
Expand Down Expand Up @@ -396,6 +397,7 @@ var deprecatedFlags = []cli.Flag{
deprecatedEnableEth1DataVoteCacheFlag,
deprecatedAccountMetricsFlag,
deprecatedEnableDomainDataCacheFlag,
deprecatedEnableByteMempool,
}

// ValidatorFlags contains a list of all the feature flags that apply to the validator client.
Expand Down Expand Up @@ -438,7 +440,6 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
cacheFilteredBlockTreeFlag,
disableStrictAttestationPubsubVerificationFlag,
disableUpdateHeadPerAttestation,
enableByteMempool,
enableStateGenSigVerify,
checkHeadState,
enableNoiseHandshake,
Expand Down
16 changes: 0 additions & 16 deletions shared/memorypool/BUILD.bazel

This file was deleted.

140 changes: 0 additions & 140 deletions shared/memorypool/memorypool.go

This file was deleted.

16 changes: 0 additions & 16 deletions shared/memorypool/memorypool_test.go

This file was deleted.

0 comments on commit 6a9112b

Please sign in to comment.