Add toggle for badger, flag out gas tracing
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
0771c23fb0
commit
55c6b88537
@ -459,9 +459,11 @@ func (rt *Runtime) stateCommit(oldh, newh cid.Cid) aerrors.ActorError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) finilizeGasTracing() {
|
func (rt *Runtime) finilizeGasTracing() {
|
||||||
|
if enableTracing {
|
||||||
if rt.lastGasCharge != nil {
|
if rt.lastGasCharge != nil {
|
||||||
rt.lastGasCharge.TimeTaken = time.Since(rt.lastGasChargeTime)
|
rt.lastGasCharge.TimeTaken = time.Since(rt.lastGasChargeTime)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChargeGas is spec actors function
|
// ChargeGas is spec actors function
|
||||||
@ -489,8 +491,11 @@ func (rt *Runtime) chargeGasFunc(skip int) func(GasCharge) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enableTracing = false
|
||||||
|
|
||||||
func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError {
|
func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError {
|
||||||
toUse := gas.Total()
|
toUse := gas.Total()
|
||||||
|
if enableTracing {
|
||||||
var callers [10]uintptr
|
var callers [10]uintptr
|
||||||
|
|
||||||
cout := 0 //gruntime.Callers(2+skip, callers[:])
|
cout := 0 //gruntime.Callers(2+skip, callers[:])
|
||||||
@ -517,6 +522,7 @@ func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError
|
|||||||
rt.executionTrace.GasCharges = append(rt.executionTrace.GasCharges, &gasTrace)
|
rt.executionTrace.GasCharges = append(rt.executionTrace.GasCharges, &gasTrace)
|
||||||
rt.lastGasChargeTime = now
|
rt.lastGasChargeTime = now
|
||||||
rt.lastGasCharge = &gasTrace
|
rt.lastGasCharge = &gasTrace
|
||||||
|
}
|
||||||
|
|
||||||
// overflow safe
|
// overflow safe
|
||||||
if rt.gasUsed > rt.gasAvailable-toUse {
|
if rt.gasUsed > rt.gasAvailable-toUse {
|
||||||
|
@ -227,16 +227,23 @@ 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)
|
||||||
|
if enableTracing {
|
||||||
rt.lastGasChargeTime = start
|
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
|
||||||
defer func() {
|
defer func() {
|
||||||
parent.gasUsed = rt.gasUsed
|
|
||||||
parent.lastGasChargeTime = rt.lastGasChargeTime
|
parent.lastGasChargeTime = rt.lastGasChargeTime
|
||||||
parent.lastGasCharge = rt.lastGasCharge
|
parent.lastGasCharge = rt.lastGasCharge
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if parent != nil {
|
||||||
|
defer func() {
|
||||||
|
parent.gasUsed += rt.gasUsed
|
||||||
|
}()
|
||||||
|
}
|
||||||
if gasCharge != nil {
|
if gasCharge != nil {
|
||||||
if err := rt.chargeGasSafe(*gasCharge); err != nil {
|
if err := rt.chargeGasSafe(*gasCharge); err != nil {
|
||||||
// this should never happen
|
// this should never happen
|
||||||
|
@ -119,15 +119,10 @@ var importBenchCmd = &cli.Command{
|
|||||||
tdir = tmp
|
tdir = tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
bdgOpt := badger.DefaultOptions
|
var bds datastore.Batching
|
||||||
bdgOpt.GcInterval = 0
|
if false {
|
||||||
bdgOpt.Options = bdg.DefaultOptions("")
|
|
||||||
bdgOpt.Options.SyncWrites = false
|
|
||||||
bdgOpt.Options.Truncate = true
|
|
||||||
bdgOpt.Options.DetectConflicts = false
|
|
||||||
|
|
||||||
cache := 512
|
cache := 512
|
||||||
bds, err := pebbleds.NewDatastore(tdir, &pebble.Options{
|
bds, err = pebbleds.NewDatastore(tdir, &pebble.Options{
|
||||||
// Pebble has a single combined cache area and the write
|
// Pebble has a single combined cache area and the write
|
||||||
// buffers are taken from this too. Assign all available
|
// buffers are taken from this too. Assign all available
|
||||||
// memory allowance for cache.
|
// memory allowance for cache.
|
||||||
@ -146,6 +141,15 @@ var importBenchCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
Logger: log,
|
Logger: log,
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
bdgOpt := badger.DefaultOptions
|
||||||
|
bdgOpt.GcInterval = 0
|
||||||
|
bdgOpt.Options = bdg.DefaultOptions("")
|
||||||
|
bdgOpt.Options.SyncWrites = false
|
||||||
|
bdgOpt.Options.Truncate = true
|
||||||
|
bdgOpt.Options.DetectConflicts = false
|
||||||
|
bds, err = badger.NewDatastore(tdir, &bdgOpt)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user