Skip to content

Commit

Permalink
remove pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
AdoAdoAdo committed Apr 29, 2024
1 parent 4794d97 commit 9f8be74
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions process/block/preprocess/smartContractResults.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package preprocess

import (
"fmt"
"math/rand"
"os"
"runtime/debug"
"runtime/pprof"
"time"

"github.com/multiversx/mx-chain-core-go/core"
Expand All @@ -16,6 +11,7 @@ import (
"github.com/multiversx/mx-chain-core-go/data/smartContractResult"
"github.com/multiversx/mx-chain-core-go/hashing"
"github.com/multiversx/mx-chain-core-go/marshal"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/dataRetriever"
"github.com/multiversx/mx-chain-go/process"
Expand Down Expand Up @@ -261,22 +257,6 @@ func (scr *smartContractResults) ProcessBlockTransactions(
totalGasConsumedInSelfShard: scr.getTotalGasConsumed(),
}

// TODO: add validator pprof
r := rand.Intn(1000)
fileName := fmt.Sprintf("logs/validator-cpu-profile-%d-%d-%d.pprof", time.Now().Unix(), len(body.MiniBlocks), r)
f, err := os.Create(fileName)
if err != nil {
log.Error("could not create CPU profile", "error", err)
}
debug.SetGCPercent(-1)
_ = pprof.StartCPUProfile(f)

defer func() {
pprof.StopCPUProfile()

log.Info("validator-cpu-profile saved", "file", fileName)
}()

log.Debug("smartContractResults.ProcessBlockTransactions: before processing",
"totalGasConsumedInSelfShard", gasInfo.totalGasConsumedInSelfShard,
"total gas provided", scr.gasHandler.TotalGasProvided(),
Expand Down Expand Up @@ -598,22 +578,6 @@ func (scr *smartContractResults) ProcessMiniBlock(
maxGasLimitUsedForDestMeTxs = scr.economicsFee.MaxGasLimitPerBlock(scr.shardCoordinator.SelfId()) * maxGasLimitPercentUsedForDestMeTxs / 100
}

//TODO: add pprof for leader, when len(miniBlockScrs) > 0
r := rand.Intn(1000)
fileName := fmt.Sprintf("logs/leader-cpu-profile-%d-%d-%d.pprof", time.Now().Unix(), len(miniBlockScrs), r)
f, err := os.Create(fileName)
if err != nil {
log.Error("could not create CPU profile", "error", err)
}
debug.SetGCPercent(-1)
_ = pprof.StartCPUProfile(f)

defer func() {
pprof.StopCPUProfile()

log.Info("leader-cpu-profile saved", "file", fileName)
}()

log.Debug("smartContractResults.ProcessMiniBlock: before processing",
"totalGasConsumedInSelfShard", gasInfo.totalGasConsumedInSelfShard,
"total gas provided", scr.gasHandler.TotalGasProvided(),
Expand Down

0 comments on commit 9f8be74

Please sign in to comment.