Expose more callers, ellipsis unimportant ones
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
82eb7786d4
commit
cd69e57a33
@ -20,35 +20,83 @@ type ExecutionTrace struct {
|
|||||||
|
|
||||||
type GasTrace struct {
|
type GasTrace struct {
|
||||||
Name string
|
Name string
|
||||||
Location string
|
|
||||||
|
Location []Loc
|
||||||
TotalGas int64
|
TotalGas int64
|
||||||
ComputeGas int64
|
ComputeGas int64
|
||||||
StorageGas int64
|
StorageGas int64
|
||||||
|
|
||||||
TimeTaken time.Duration
|
TimeTaken time.Duration
|
||||||
|
Extra interface{}
|
||||||
|
|
||||||
Callers []uintptr `json:"-"`
|
Callers []uintptr `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Loc struct {
|
||||||
|
File string
|
||||||
|
Line int
|
||||||
|
Function string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l Loc) Show() bool {
|
||||||
|
ignorePrefix := []string{
|
||||||
|
"reflect.",
|
||||||
|
"github.com/filecoin-project/lotus/chain/vm.(*Invoker).transform",
|
||||||
|
"github.com/filecoin-project/go-amt-ipld/",
|
||||||
|
}
|
||||||
|
for _, pre := range ignorePrefix {
|
||||||
|
if strings.HasPrefix(l.Function, pre) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
func (l Loc) String() string {
|
||||||
|
file := strings.Split(l.File, "/")
|
||||||
|
|
||||||
|
fn := strings.Split(l.Function, "/")
|
||||||
|
var fnpkg string
|
||||||
|
if len(fn) > 2 {
|
||||||
|
fnpkg = strings.Join(fn[len(fn)-2:], "/")
|
||||||
|
} else {
|
||||||
|
fnpkg = l.Function
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s@%s:%d", fnpkg, file[len(file)-1], l.Line)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l Loc) Important() bool {
|
||||||
|
if strings.HasPrefix(l.Function, "github.com/filecoin-project/specs-actors/actors/builtin") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (gt *GasTrace) MarshalJSON() ([]byte, error) {
|
func (gt *GasTrace) MarshalJSON() ([]byte, error) {
|
||||||
type GasTraceCopy GasTrace
|
type GasTraceCopy GasTrace
|
||||||
if gt.Location == "" {
|
if len(gt.Location) == 0 {
|
||||||
if len(gt.Callers) != 0 {
|
if len(gt.Callers) != 0 {
|
||||||
frames := runtime.CallersFrames(gt.Callers)
|
frames := runtime.CallersFrames(gt.Callers)
|
||||||
for {
|
for {
|
||||||
frame, more := frames.Next()
|
frame, more := frames.Next()
|
||||||
fn := strings.Split(frame.Function, "/")
|
if frame.Function == "github.com/filecoin-project/lotus/chain/vm.(*VM).ApplyMessage" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
l := Loc{
|
||||||
|
File: frame.File,
|
||||||
|
Line: frame.Line,
|
||||||
|
Function: frame.Function,
|
||||||
|
}
|
||||||
|
//fn := strings.Split(frame.Function, "/")
|
||||||
|
|
||||||
split := strings.Split(frame.File, "/")
|
//split := strings.Split(frame.File, "/")
|
||||||
file := strings.Join(split[len(split)-2:], "/")
|
//file := strings.Join(split[len(split)-2:], "/")
|
||||||
gt.Location += fmt.Sprintf("%s@%s:%d", fn[len(fn)-1], file, frame.Line)
|
//gt.Location += fmt.Sprintf("%s@%s:%d", fn[len(fn)-1], file, frame.Line)
|
||||||
|
gt.Location = append(gt.Location, l)
|
||||||
if !more {
|
if !more {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
gt.Location += "|"
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
gt.Location = "n/a"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,22 +488,33 @@ func (rt *Runtime) stateCommit(oldh, newh cid.Cid) aerrors.ActorError {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) ChargeGas(gas GasCharge) {
|
|
||||||
err := rt.chargeGasInternal(gas)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (rt *Runtime) finilizeGasTracing() {
|
func (rt *Runtime) finilizeGasTracing() {
|
||||||
if rt.lastGasCharge != nil {
|
if rt.lastGasCharge != nil {
|
||||||
rt.lastGasCharge.TimeTaken = time.Since(rt.lastGasChargeTime)
|
rt.lastGasCharge.TimeTaken = time.Since(rt.lastGasChargeTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) chargeGasInternal(gas GasCharge) aerrors.ActorError {
|
func (rt *Runtime) ChargeGas(gas GasCharge) {
|
||||||
|
err := rt.chargeGasInternal(gas, 1)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rt *Runtime) chargeGasFunc(skip int) func(GasCharge) {
|
||||||
|
return func(gas GasCharge) {
|
||||||
|
err := rt.chargeGasInternal(gas, 1+skip)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError {
|
||||||
toUse := gas.Total()
|
toUse := gas.Total()
|
||||||
var callers [3]uintptr
|
var callers [10]uintptr
|
||||||
cout := gruntime.Callers(3, callers[:])
|
cout := gruntime.Callers(2+skip, callers[:])
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if rt.lastGasCharge != nil {
|
if rt.lastGasCharge != nil {
|
||||||
@ -530,7 +541,7 @@ func (rt *Runtime) chargeGasInternal(gas GasCharge) aerrors.ActorError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) chargeGasSafe(gas GasCharge) aerrors.ActorError {
|
func (rt *Runtime) chargeGasSafe(gas GasCharge) aerrors.ActorError {
|
||||||
return rt.chargeGasInternal(gas)
|
return rt.chargeGasInternal(gas, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) Pricelist() Pricelist {
|
func (rt *Runtime) Pricelist() Pricelist {
|
||||||
|
@ -107,12 +107,12 @@ func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin addres
|
|||||||
}
|
}
|
||||||
|
|
||||||
rt.cst = &cbor.BasicIpldStore{
|
rt.cst = &cbor.BasicIpldStore{
|
||||||
Blocks: &gasChargingBlocks{rt.ChargeGas, rt.pricelist, vm.cst.Blocks},
|
Blocks: &gasChargingBlocks{rt.chargeGasFunc(2), rt.pricelist, vm.cst.Blocks},
|
||||||
Atlas: vm.cst.Atlas,
|
Atlas: vm.cst.Atlas,
|
||||||
}
|
}
|
||||||
rt.sys = pricedSyscalls{
|
rt.sys = pricedSyscalls{
|
||||||
under: vm.Syscalls,
|
under: vm.Syscalls,
|
||||||
chargeGas: rt.ChargeGas,
|
chargeGas: rt.chargeGasFunc(1),
|
||||||
pl: rt.pricelist,
|
pl: rt.pricelist,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
cli/state.go
44
cli/state.go
@ -974,7 +974,33 @@ var compStateTemplate = `
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
tr.sum { border-top: 1px solid black; }
|
tr {
|
||||||
|
border-top: 1px solid black;
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
}
|
||||||
|
tr.sum { border-top: 2px solid black; }
|
||||||
|
tr:first-child { border-top: none; }
|
||||||
|
tr:last-child { border-bottom: none; }
|
||||||
|
|
||||||
|
|
||||||
|
.ellipsis-content,
|
||||||
|
.ellipsis-toggle input {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.ellipsis-toggle {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
Checked State
|
||||||
|
**/
|
||||||
|
|
||||||
|
.ellipsis-toggle input:checked + .ellipsis {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.ellipsis-toggle input:checked ~ .ellipsis-content {
|
||||||
|
display: inline;
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -1028,7 +1054,21 @@ var compStateMsg = `
|
|||||||
<table>
|
<table>
|
||||||
<tr><th>Name</th><th>Total/Compute/Storage</th><th>Time Taken</th><th>Location</th></tr>
|
<tr><th>Name</th><th>Total/Compute/Storage</th><th>Time Taken</th><th>Location</th></tr>
|
||||||
{{range .GasCharges}}
|
{{range .GasCharges}}
|
||||||
<tr><td>{{.Name}}</td><td>{{.TotalGas}}/{{.ComputeGas}}/{{.StorageGas}}</td><td>{{.TimeTaken}}</td><td>{{.Location}}</td></tr>
|
<tr><td>{{.Name}}</td><td>{{.TotalGas}}/{{.ComputeGas}}/{{.StorageGas}}</td><td>{{.TimeTaken}}</td>
|
||||||
|
<td>
|
||||||
|
{{ range $index, $ele := .Location }}
|
||||||
|
{{- if $index }}|​{{end -}}
|
||||||
|
{{- if .Show -}}
|
||||||
|
{{- if .Important }}<b>{{end -}}
|
||||||
|
{{- . -}}
|
||||||
|
{{- if .Important }}</b>{{end -}}
|
||||||
|
{{- else -}}
|
||||||
|
<label class="ellipsis-toggle"><input type="checkbox" /><span class="ellipsis">...</span>
|
||||||
|
{{- "" -}}
|
||||||
|
<span class="ellipsis-content">{{- . -}}</span></label>
|
||||||
|
{{- end -}}
|
||||||
|
{{end}}
|
||||||
|
</td></tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{with SumGas .GasCharges}}
|
{{with SumGas .GasCharges}}
|
||||||
<tr class="sum"><td><b>Sum</b></td><td>{{.TotalGas}}/{{.ComputeGas}}/{{.StorageGas}}</td><td>{{.TimeTaken}}</td><td></td></tr>
|
<tr class="sum"><td><b>Sum</b></td><td>{{.TotalGas}}/{{.ComputeGas}}/{{.StorageGas}}</td><td>{{.TimeTaken}}</td><td></td></tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user