-
Notifications
You must be signed in to change notification settings - Fork 204
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
use goroutines manager for trie commit #6611
use goroutines manager for trie commit #6611
Conversation
…actor-trie-commit # Conflicts: # common/interface.go # trie/branchNode_test.go # trie/extensionNode_test.go # trie/patriciaMerkleTrie.go
…actor-trie-commit # Conflicts: # trie/branchNode.go # trie/extensionNode_test.go # trie/patriciaMerkleTrie.go # trie/rootManager.go
…actor-trie-commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add unit tests on this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
@@ -353,23 +354,30 @@ func (tr *patriciaMerkleTrie) Commit() error { | |||
return nil | |||
} | |||
|
|||
oldRootHash := tr.GetOldRootHash() | |||
if log.GetLevel() == logger.LogTrace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was helpful for some debugging scenarios. I would leave it like this for now.
trie/branchNode.go
Outdated
encNode, err := bn.getEncodedNode() | ||
if err != nil { | ||
return err | ||
goRoutinesManager.SetError(err) | ||
return | ||
} | ||
hash := bn.hasher.Compute(string(encNode)) | ||
bn.hash = hash | ||
hashesCollector.AddDirtyHash(hash) | ||
|
||
err = targetDb.Put(hash, encNode) | ||
if err != nil { | ||
goRoutinesManager.SetError(err) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have like a common function for this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems similar with extention and leaf node code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, extracted in a separate function.
@@ -1,6 +1,7 @@ | |||
package syncer | |||
|
|||
import ( | |||
"github.com/multiversx/mx-chain-go/state/hashesCollector" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goimport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
trie/depthFirstSync_test.go
Outdated
@@ -4,6 +4,7 @@ import ( | |||
"bytes" | |||
"context" | |||
"fmt" | |||
"github.com/multiversx/mx-chain-go/state/hashesCollector" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goimport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
update/genesis/import.go
Outdated
@@ -5,6 +5,7 @@ import ( | |||
"encoding/hex" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/multiversx/mx-chain-go/state/hashesCollector" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goimport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
// NewDataTrieHashesCollector creates a new instance of dataTrieHashesCollector. | ||
// This collector is used to collect hashes related to the data trie. | ||
func NewDataTrieHashesCollector() *dataTrieHashesCollector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make a new one for this every single time ? and that is why you do not have delete function ?
I think adding some capacity on the creation of the oldHashes / newHashes can make processing faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Added a capacity of 10k. That means 10000 hashes => 320kB
state/accountsDB.go
Outdated
oldHashes := make(common.ModifiedHashes) | ||
newHashes := make(common.ModifiedHashes) | ||
hc := hashesCollector.NewDisabledHashesCollector() | ||
if adb.mainTrie.GetStorageManager().IsPruningEnabled() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a separate function for this 3 lines -> and could we have without NEW at every single commit? like you could have a cleanup function here -> might be faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this if you could have a factory - which creates the good structure by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a cleanup function. There is no need for a factory after the changes since we create the component on the constructor.
state/accountsDB.go
Outdated
} | ||
} | ||
|
||
func createTheHashesCollector(mainTrie common.Trie) common.TrieHashesCollector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func createTheHashesCollector(mainTrie common.Trie) common.TrieHashesCollector { | |
func createTrieHashesCollector(mainTrie common.Trie) common.TrieHashesCollector { |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
The base branch was changed.
Reasoning behind the pull request
GetObsoleteHashes
,GetDirtyHashes
,GetOldRoot
. These can be extracted in a new componentProposed changes
hashesCollector
which gathers all the necessary data for aCommit
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?