Skip to content

Commit

Permalink
Change OnIpldGet
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sztandera <[email protected]>
  • Loading branch information
Jakub Sztandera committed Jul 15, 2020
1 parent 399c171 commit 610ed0d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion chain/vm/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type Pricelist interface {
OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge

// OnIpldGet returns the gas used for storing an object
OnIpldGet(dataSize int) GasCharge
OnIpldGet() GasCharge
// OnIpldPut returns the gas used for storing an object
OnIpldPut(dataSize int) GasCharge

Expand Down
2 changes: 1 addition & 1 deletion chain/vm/gas_v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.M
}

// OnIpldGet returns the gas used for storing an object
func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge {
func (pl *pricelistV0) OnIpldGet() GasCharge {
return newGasCharge("OnIpldGet", pl.ipldGetBase, 0)
}

Expand Down
4 changes: 2 additions & 2 deletions chain/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ type gasChargingBlocks struct {
}

func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) {
bs.chargeGas(newGasCharge("OnIpldGetStart", 0, 0))
bs.chargeGas(bs.pricelist.OnIpldGet())
blk, err := bs.under.Get(c)
if err != nil {
return nil, aerrors.Escalate(err, "failed to get block from blockstore")
}
bs.chargeGas(bs.pricelist.OnIpldGet(len(blk.RawData())))
bs.chargeGas(newGasCharge("OnIpldGetEnd", 0, 0).WithExtra(len(blk.RawData())))
bs.chargeGas(gasOnActorExec)

return blk, nil
Expand Down
13 changes: 8 additions & 5 deletions cmd/lotus-bench/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,19 @@ func getExtras(ex interface{}) (*string, *float64) {
func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
for i, gc := range et.GasCharges {
name := gc.Name
if name == "OnIpldGetStart" {
if name == "OnIpldGetEnd" {
continue
}
tt := float64(gc.TimeTaken.Nanoseconds())
if name == "OnIpldGet" {
prev := et.GasCharges[i-1]
if prev.Name != "OnIpldGetStart" {
log.Warn("OnIpldGet without OnIpldGetStart")
next := &types.GasTrace{}
if i+1 < len(et.GasCharges) {
next = et.GasCharges[i+1]
}
tt += float64(prev.TimeTaken.Nanoseconds())
if next.Name != "OnIpldGetEnd" {
log.Warn("OnIpldGet without OnIpldGetEnd")
}
tt += float64(next.TimeTaken.Nanoseconds())
}
eType, eSize := getExtras(gc.Extra)
if eType != nil {
Expand Down

0 comments on commit 610ed0d

Please sign in to comment.