Skip to content
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

cmd: fix memory leak when big dataset #2455

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
ci: fix ci lint error
  • Loading branch information
fynnss committed May 14, 2024
commit bb38b1fceb229fc7c81d0d41ec741c8fc098bf8c
2 changes: 1 addition & 1 deletion cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Remove blockchain and state databases`,
utils.DataDirFlag,
utils.SyncModeFlag,
},
Usage: "Inspect the MPT tree of the account and contract. the blocknum arg can be latest/snapshot/number.",
Usage: "Inspect the MPT tree of the account and contract. 'blocknum' can be latest/snapshot/number. 'topn' means output the top N storage tries info ranked by the total number of TrieNodes",
Description: `This commands iterates the entrie WorldState.`,
}
dbCheckStateContentCmd = &cli.Command{
Expand Down
11 changes: 2 additions & 9 deletions trie/inspect_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type stat struct {
}

type trieStat struct {
lock sync.RWMutex
owner common.Hash
totalNodeStat nodeStat
nodeStatByLevel [16]nodeStat
Expand Down Expand Up @@ -140,7 +139,7 @@ func (trieStat *trieStat) Display(ownerAddress string, treeType string) string {
}
table.SetAlignment(1)

for i, _ := range trieStat.nodeStatByLevel {
for i := range trieStat.nodeStatByLevel {
if trieStat.nodeStatByLevel[i].IsEmpty() {
continue
}
Expand Down Expand Up @@ -191,7 +190,6 @@ func NewInspector(tr *Trie, db Database, stateRootHash common.Hash, blockNum uin

// Run statistics, external call
func (s *Inspector) Run() {

ticker := time.NewTicker(30 * time.Second)
go func() {
defer ticker.Stop()
Expand Down Expand Up @@ -304,14 +302,9 @@ func (s *Inspector) DisplayResult() {
fmt.Println(s.results.account.Display("", "AccountTrie"))
fmt.Println("EOA accounts num: ", s.eoaAccountNums)

type SortedTrie struct {
totalNum uint64
ownerAddress string
}
// display contract trie
for _, st := range s.results.storageTopN {
fmt.Printf(st.Display(st.owner.String(), "StorageTrie"))

fmt.Println(st.Display(st.owner.String(), "StorageTrie"))
}
fmt.Printf("Contract Trie, total trie num: %v, ShortNodeCnt: %v, FullNodeCnt: %v, ValueNodeCnt: %v\n",
s.results.storageTrieNum, s.results.storageTotal.ShortNodeCnt.Load(), s.results.storageTotal.FullNodeCnt.Load(), s.results.storageTotal.ValueNodeCnt.Load())
Expand Down
Loading