Skip to content

PALL base Fastdb #6

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

Open
wants to merge 2 commits into
base: fastdb
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func ImportChain(chain *core.BlockChain, fn string) error {
return fmt.Errorf("invalid block %d: %v", n, err)
}
}
common.DebugInfo.Print()
return nil
}

Expand Down
47 changes: 47 additions & 0 deletions common/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ package common

import (
"fmt"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/mem"
"os"
"runtime"
"runtime/debug"
"strings"
"time"
)

// Report gives off a warning requesting the user to submit an issue to the github tracker.
Expand Down Expand Up @@ -50,3 +53,47 @@ func PrintDepricationWarning(str string) {

`, line, emptyLine, str, emptyLine, line)
}

type DebugTime struct {
ExecuteTx time.Duration
ValidateBlock time.Duration
WriteBlock time.Duration
CommitTrie time.Duration
TxLen int
}

func NewDebugTime() *DebugTime {
d := &DebugTime{
ExecuteTx: time.Duration(0),
ValidateBlock: time.Duration(0),
WriteBlock: time.Duration(0),
CommitTrie: time.Duration(0),
}
go d.cpuAndMem()
return d

}

func (d *DebugTime) cpuAndMem() {
for true {
v, _ := mem.VirtualMemory()
res, _ := cpu.Times(false)
fmt.Println("mem info", v)
fmt.Println("cpu info", res)
time.Sleep(10 * time.Minute)
}
}

func (d *DebugTime) Print() {
fmt.Println("总的交易数目", d.TxLen)

fmt.Println("执行区块用时", d.ExecuteTx)
fmt.Println("验证区块用时", d.ValidateBlock)
fmt.Println("写入区块用时", d.WriteBlock)
fmt.Println("写入trie用时", d.CommitTrie)
}

var (
DebugInfo = NewDebugTime()
BlockExecuteBatch = int(1)
)
6 changes: 5 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1814,12 +1814,14 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
//}
// Process block using the parent state as reference point
substart := time.Now()
receipts, logs, usedGas, err := bc.processor.Process(block, statedb, bc.vmConfig)
receipts, logs, usedGas, err := bc.processor.PallProcess(block, statedb, bc.vmConfig)
if err != nil {
bc.reportBlock(block, receipts, err)
atomic.StoreUint32(&followupInterrupt, 1)
return it.index, err
}
common.DebugInfo.ExecuteTx += time.Since(substart)

// Update the metrics touched during block processing
accountReadTimer.Update(statedb.AccountReads) // Account reads are complete, we can mark them
storageReadTimer.Update(statedb.StorageReads) // Storage reads are complete, we can mark them
Expand All @@ -1841,6 +1843,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
atomic.StoreUint32(&followupInterrupt, 1)
return it.index, err
}

common.DebugInfo.ValidateBlock += time.Since(substart)
proctime := time.Since(start)

// Update the metrics touched during block validation
Expand Down
Loading