Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization: encode hash to hex only on log TRACE level set #6338

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions trie/patriciaMerkleTrie.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/hashing"
"github.com/multiversx/mx-chain-core-go/marshal"
logger "github.com/multiversx/mx-chain-logger-go"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/dataRetriever"
"github.com/multiversx/mx-chain-go/errors"
"github.com/multiversx/mx-chain-go/trie/keyBuilder"
"github.com/multiversx/mx-chain-go/trie/statistics"
logger "github.com/multiversx/mx-chain-logger-go"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
)

var log = logger.GetOrCreate("trie")
Expand Down Expand Up @@ -118,10 +119,12 @@ func (tr *patriciaMerkleTrie) Update(key, value []byte) error {
tr.mutOperation.Lock()
defer tr.mutOperation.Unlock()

log.Trace("update trie",
"key", hex.EncodeToString(key),
"val", hex.EncodeToString(value),
)
if log.GetLevel() == logger.LogTrace {
log.Trace("update trie",
"key", hex.EncodeToString(key),
"val", hex.EncodeToString(value),
)
}

return tr.update(key, value, core.NotSpecified)
}
Expand All @@ -131,11 +134,13 @@ func (tr *patriciaMerkleTrie) UpdateWithVersion(key []byte, value []byte, versio
tr.mutOperation.Lock()
defer tr.mutOperation.Unlock()

log.Trace("update trie with version",
"key", hex.EncodeToString(key),
"val", hex.EncodeToString(value),
"version", version,
)
if log.GetLevel() == logger.LogTrace {
log.Trace("update trie with version",
"key", hex.EncodeToString(key),
"val", hex.EncodeToString(value),
"version", version,
)
}

return tr.update(key, value, version)
}
Expand Down
Loading