From 10c4fae8c08ae2931ea1fd88c5cce7c2fafde9b6 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 25 Jun 2020 16:46:50 +0200 Subject: [PATCH 1/2] Make gas traces smaller, strip callers in import-bench Signed-off-by: Jakub Sztandera --- chain/types/execresult.go | 18 +++++++++--------- chain/vm/runtime.go | 2 +- cmd/lotus-bench/import.go | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/chain/types/execresult.go b/chain/types/execresult.go index 443147f9e..6fc93fac6 100644 --- a/chain/types/execresult.go +++ b/chain/types/execresult.go @@ -21,16 +21,16 @@ type ExecutionTrace struct { type GasTrace struct { Name string - Location []Loc - TotalGas int64 - ComputeGas int64 - StorageGas int64 - TotalVirtualGas int64 - VirtualComputeGas int64 - VirtualStorageGas int64 + Location []Loc `json:"loc"` + TotalGas int64 `json:"tg"` + ComputeGas int64 `json:"cg"` + StorageGas int64 `json:"sg"` + TotalVirtualGas int64 `json:"vtg"` + VirtualComputeGas int64 `json:"vcg"` + VirtualStorageGas int64 `json:"vsg"` - TimeTaken time.Duration - Extra interface{} `json:",omitempty"` + TimeTaken time.Duration `json:"tt"` + Extra interface{} `json:"ex,omitempty"` Callers []uintptr `json:"-"` } diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index d6d49c214..595664de1 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -408,7 +408,7 @@ func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, if subrt != nil { rt.numActorsCreated = subrt.numActorsCreated } - rt.executionTrace.Subcalls = append(rt.executionTrace.Subcalls, subrt.executionTrace) //&er) + rt.executionTrace.Subcalls = append(rt.executionTrace.Subcalls, subrt.executionTrace) return ret, errSend } diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index f7538daec..647bb58ed 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -149,6 +149,7 @@ var importBenchCmd = &cli.Command{ if err != nil { return err } + stripCallers(trace) lastTse = &TipSetExec{ TipSet: cur.Key(), @@ -168,6 +169,21 @@ var importBenchCmd = &cli.Command{ }, } +func walkExecutionTrace(et *types.ExecutionTrace) { + for _, gc := range et.GasCharges { + gc.Callers = nil + } + for _, sub := range et.Subcalls { + walkExecutionTrace(&sub) + } +} + +func stripCallers(trace []*api.InvocResult) { + for _, t := range trace { + walkExecutionTrace(&t.ExecutionTrace) + } +} + type Invocation struct { TipSet types.TipSetKey Invoc *api.InvocResult From f98063d60476c4ef6cd0e0876d72dede647a1d13 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 25 Jun 2020 16:58:55 +0200 Subject: [PATCH 2/2] In this case I want it to be not really safe Signed-off-by: Jakub Sztandera --- cmd/lotus-bench/import.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index 647bb58ed..ebc62aa5d 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -174,7 +174,7 @@ func walkExecutionTrace(et *types.ExecutionTrace) { gc.Callers = nil } for _, sub := range et.Subcalls { - walkExecutionTrace(&sub) + walkExecutionTrace(&sub) //nolint:scopelint,gosec } }