Change ellipsis, more accurate timing
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
8ad2b3c3d9
commit
91ea039077
@ -371,6 +371,8 @@ func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMars
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, value types.BigInt, params []byte) ([]byte, aerrors.ActorError) {
|
func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, value types.BigInt, params []byte) ([]byte, aerrors.ActorError) {
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
ctx, span := trace.StartSpan(rt.ctx, "vmc.Send")
|
ctx, span := trace.StartSpan(rt.ctx, "vmc.Send")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
if span.IsRecordingEvents() {
|
if span.IsRecordingEvents() {
|
||||||
@ -396,7 +398,7 @@ func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum,
|
|||||||
}
|
}
|
||||||
defer st.ClearSnapshot()
|
defer st.ClearSnapshot()
|
||||||
|
|
||||||
ret, errSend, subrt := rt.vm.send(ctx, msg, rt, nil)
|
ret, errSend, subrt := rt.vm.send(ctx, msg, rt, nil, start)
|
||||||
if errSend != nil {
|
if errSend != nil {
|
||||||
if errRevert := st.Revert(); errRevert != nil {
|
if errRevert := st.Revert(); errRevert != nil {
|
||||||
return nil, aerrors.Escalate(errRevert, "failed to revert state tree after failed subcall")
|
return nil, aerrors.Escalate(errRevert, "failed to revert state tree after failed subcall")
|
||||||
|
@ -96,14 +96,13 @@ func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin addres
|
|||||||
originNonce: originNonce,
|
originNonce: originNonce,
|
||||||
height: vm.blockHeight,
|
height: vm.blockHeight,
|
||||||
|
|
||||||
gasUsed: usedGas,
|
gasUsed: usedGas,
|
||||||
gasAvailable: msg.GasLimit,
|
gasAvailable: msg.GasLimit,
|
||||||
numActorsCreated: nac,
|
numActorsCreated: nac,
|
||||||
pricelist: PricelistByEpoch(vm.blockHeight),
|
pricelist: PricelistByEpoch(vm.blockHeight),
|
||||||
allowInternal: true,
|
allowInternal: true,
|
||||||
callerValidated: false,
|
callerValidated: false,
|
||||||
executionTrace: types.ExecutionTrace{Msg: msg},
|
executionTrace: types.ExecutionTrace{Msg: msg},
|
||||||
lastGasChargeTime: time.Now(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rt.cst = &cbor.BasicIpldStore{
|
rt.cst = &cbor.BasicIpldStore{
|
||||||
@ -172,8 +171,7 @@ type ApplyRet struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||||
gasCharge *GasCharge) ([]byte, aerrors.ActorError, *Runtime) {
|
gasCharge *GasCharge, start time.Time) ([]byte, aerrors.ActorError, *Runtime) {
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
st := vm.cstate
|
st := vm.cstate
|
||||||
|
|
||||||
@ -189,6 +187,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)
|
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)
|
||||||
|
rt.lastGasChargeTime = start
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
rt.lastGasChargeTime = parent.lastGasChargeTime
|
rt.lastGasChargeTime = parent.lastGasChargeTime
|
||||||
rt.lastGasCharge = parent.lastGasCharge
|
rt.lastGasCharge = parent.lastGasCharge
|
||||||
@ -273,7 +272,8 @@ func checkMessage(msg *types.Message) error {
|
|||||||
|
|
||||||
func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) {
|
func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
ret, actorErr, rt := vm.send(ctx, msg, nil, nil)
|
ret, actorErr, rt := vm.send(ctx, msg, nil, nil, start)
|
||||||
|
rt.finilizeGasTracing()
|
||||||
return &ApplyRet{
|
return &ApplyRet{
|
||||||
MessageReceipt: types.MessageReceipt{
|
MessageReceipt: types.MessageReceipt{
|
||||||
ExitCode: aerrors.RetCode(actorErr),
|
ExitCode: aerrors.RetCode(actorErr),
|
||||||
@ -390,8 +390,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
|||||||
}
|
}
|
||||||
defer st.ClearSnapshot()
|
defer st.ClearSnapshot()
|
||||||
|
|
||||||
ret, actorErr, rt := vm.send(ctx, msg, nil, &msgGas)
|
ret, actorErr, rt := vm.send(ctx, msg, nil, &msgGas, start)
|
||||||
rt.finilizeGasTracing()
|
|
||||||
if aerrors.IsFatal(actorErr) {
|
if aerrors.IsFatal(actorErr) {
|
||||||
return nil, xerrors.Errorf("[from=%s,to=%s,n=%d,m=%d,h=%d] fatal error: %w", msg.From, msg.To, msg.Nonce, msg.Method, vm.blockHeight, actorErr)
|
return nil, xerrors.Errorf("[from=%s,to=%s,n=%d,m=%d,h=%d] fatal error: %w", msg.From, msg.To, msg.Nonce, msg.Method, vm.blockHeight, actorErr)
|
||||||
}
|
}
|
||||||
@ -445,6 +444,8 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
|||||||
return nil, xerrors.Errorf("gas handling math is wrong")
|
return nil, xerrors.Errorf("gas handling math is wrong")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rt.finilizeGasTracing()
|
||||||
|
|
||||||
return &ApplyRet{
|
return &ApplyRet{
|
||||||
MessageReceipt: types.MessageReceipt{
|
MessageReceipt: types.MessageReceipt{
|
||||||
ExitCode: errcode,
|
ExitCode: errcode,
|
||||||
|
89
cli/state.go
89
cli/state.go
@ -1001,6 +1001,12 @@ var compStateTemplate = `
|
|||||||
display: inline;
|
display: inline;
|
||||||
background-color: #ddd;
|
background-color: #ddd;
|
||||||
}
|
}
|
||||||
|
hr {
|
||||||
|
border: none;
|
||||||
|
height: 1px;
|
||||||
|
background-color: black;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -1049,32 +1055,54 @@ var compStateMsg = `
|
|||||||
<div class="error">Error: <pre>{{.Error}}</pre></div>
|
<div class="error">Error: <pre>{{.Error}}</pre></div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Gas Trace</summary>
|
<summary>Gas Trace</summary>
|
||||||
<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>
|
<tr><td>{{.Name}}</td><td>{{.TotalGas}}/{{.ComputeGas}}/{{.StorageGas}}</td><td>{{.TimeTaken}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{ range $index, $ele := .Location }}
|
{{ $fImp := FirstImportant .Location }}
|
||||||
{{- if $index }}|​{{end -}}
|
{{ if $fImp }}
|
||||||
{{- if .Show -}}
|
<details>
|
||||||
{{- if .Important }}<b>{{end -}}
|
<summary>{{ $fImp }}</summary><hr />
|
||||||
{{- . -}}
|
{{ $elipOn := false }}
|
||||||
{{- if .Important }}</b>{{end -}}
|
{{ range $index, $ele := .Location -}}
|
||||||
{{- else -}}
|
{{- if $index }}<br />{{end -}}
|
||||||
<label class="ellipsis-toggle"><input type="checkbox" /><span class="ellipsis">...</span>
|
{{- if .Show -}}
|
||||||
{{- "" -}}
|
{{ if $elipOn }}
|
||||||
<span class="ellipsis-content">{{- . -}}</span></label>
|
{{ $elipOn = false }}
|
||||||
{{- end -}}
|
</span></label>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{- if .Important }}<b>{{end -}}
|
||||||
|
{{- . -}}
|
||||||
|
{{if .Important }}</b>{{end}}
|
||||||
|
{{else}}
|
||||||
|
{{ if not $elipOn }}
|
||||||
|
{{ $elipOn = true }}
|
||||||
|
<label class="ellipsis-toggle"><input type="checkbox" /><span class="ellipsis">[…]<br /></span>
|
||||||
|
<span class="ellipsis-content">
|
||||||
|
{{end}}
|
||||||
|
{{- "" -}}
|
||||||
|
{{- . -}}
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
{{ if $elipOn }}
|
||||||
|
{{ $elipOn = false }}
|
||||||
|
</span></label>
|
||||||
{{end}}
|
{{end}}
|
||||||
</td></tr>
|
</details>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{with SumGas .GasCharges}}
|
</td></tr>
|
||||||
<tr class="sum"><td><b>Sum</b></td><td>{{.TotalGas}}/{{.ComputeGas}}/{{.StorageGas}}</td><td>{{.TimeTaken}}</td><td></td></tr>
|
{{end}}
|
||||||
{{end}}
|
{{with SumGas .GasCharges}}
|
||||||
</table>
|
<tr class="sum"><td><b>Sum</b></td><td>{{.TotalGas}}/{{.ComputeGas}}/{{.StorageGas}}</td><td>{{.TimeTaken}}</td><td></td></tr>
|
||||||
</details>
|
{{end}}
|
||||||
|
</table>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
{{if gt (len .Subcalls) 0}}
|
{{if gt (len .Subcalls) 0}}
|
||||||
<div>Subcalls:</div>
|
<div>Subcalls:</div>
|
||||||
{{$hash := .Hash}}
|
{{$hash := .Hash}}
|
||||||
@ -1102,6 +1130,17 @@ func computeStateHTMLTempl(ts *types.TipSet, o *api.ComputeStateOutput, getCode
|
|||||||
"SumGas": sumGas,
|
"SumGas": sumGas,
|
||||||
"CodeStr": codeStr,
|
"CodeStr": codeStr,
|
||||||
"Call": call,
|
"Call": call,
|
||||||
|
"FirstImportant": func(locs []types.Loc) *types.Loc {
|
||||||
|
if len(locs) != 0 {
|
||||||
|
for _, l := range locs {
|
||||||
|
if l.Important() {
|
||||||
|
return &l
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &locs[0]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
}).Parse(compStateTemplate)
|
}).Parse(compStateTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user