Merge pull request #10827 from filecoin-project/10585-address-review-comments

10585 address review comments
This commit is contained in:
Friðrik Ásmundsson 2023-05-04 18:32:04 +00:00 committed by GitHub
commit e6c8072f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 9 deletions

View File

@ -1,5 +1,11 @@
# Lotus changelog # Lotus changelog
# UNRELEASED
## New features
- feat: Added new environment variable `LOTUS_EXEC_TRACE_CACHE_SIZE` to configure execution trace cache size ([filecoin-project/lotus#10585](https://github.com/filecoin-project/lotus/pull/10585))
- If unset, we default to caching 16 most recent execution traces. Node operatores may want to set this to 0 while exchanges may want to crank it up.
# v1.23.0 / 2023-04-21 # v1.23.0 / 2023-04-21
This is the stable feature release for the upcoming MANDATORY network upgrade at `2023-04-27T13:00:00Z`, epoch `2809800`. This feature release delivers the nv19 Lighting and nv20 Thunder network upgrade for mainnet, and includes numerous improvements and enhancements for node operators, ETH RPC-providers and storage providers. This is the stable feature release for the upcoming MANDATORY network upgrade at `2023-04-27T13:00:00Z`, epoch `2809800`. This feature release delivers the nv19 Lighting and nv20 Thunder network upgrade for mainnet, and includes numerous improvements and enhancements for node operators, ETH RPC-providers and storage providers.

View File

@ -131,7 +131,7 @@ func (sm *StateManager) ExecutionTrace(ctx context.Context, ts *types.TipSet) (c
tsKey := ts.Key() tsKey := ts.Key()
// check if we have the trace for this tipset in the cache // check if we have the trace for this tipset in the cache
if defaultExecTraceCacheSize > 0 { if execTraceCacheSize > 0 {
sm.execTraceCacheLock.Lock() sm.execTraceCacheLock.Lock()
if entry, ok := sm.execTraceCache.Get(tsKey); ok { if entry, ok := sm.execTraceCache.Get(tsKey); ok {
// we have to make a deep copy since caller can modify the invocTrace // we have to make a deep copy since caller can modify the invocTrace
@ -149,7 +149,7 @@ func (sm *StateManager) ExecutionTrace(ctx context.Context, ts *types.TipSet) (c
return cid.Undef, nil, err return cid.Undef, nil, err
} }
if defaultExecTraceCacheSize > 0 { if execTraceCacheSize > 0 {
invocTraceCopy := makeDeepCopy(invocTrace) invocTraceCopy := makeDeepCopy(invocTrace)
sm.execTraceCacheLock.Lock() sm.execTraceCacheLock.Lock()

View File

@ -42,7 +42,7 @@ import (
const LookbackNoLimit = api.LookbackNoLimit const LookbackNoLimit = api.LookbackNoLimit
const ReceiptAmtBitwidth = 3 const ReceiptAmtBitwidth = 3
var defaultExecTraceCacheSize = 16 var execTraceCacheSize = 16
var log = logging.Logger("statemgr") var log = logging.Logger("statemgr")
type StateManagerAPI interface { type StateManagerAPI interface {
@ -76,12 +76,12 @@ func (m *migrationResultCache) keyForMigration(root cid.Cid) dstore.Key {
} }
func init() { func init() {
if s := os.Getenv("LOTUS_EXEC_TRACE_CACHE"); s != "" { if s := os.Getenv("LOTUS_EXEC_TRACE_CACHE_SIZE"); s != "" {
letc, err := strconv.Atoi(s) letc, err := strconv.Atoi(s)
if err != nil { if err != nil {
log.Errorf("failed to parse 'LOTUS_EXEC_TRACE_CACHE' env var: %s", err) log.Errorf("failed to parse 'LOTUS_EXEC_TRACE_CACHE_SIZE' env var: %s", err)
} else { } else {
defaultExecTraceCacheSize = letc execTraceCacheSize = letc
} }
} }
} }
@ -212,11 +212,11 @@ func NewStateManager(cs *store.ChainStore, exec Executor, sys vm.SyscallBuilder,
} }
} }
log.Debugf("execTraceCache size: %d", defaultExecTraceCacheSize) log.Debugf("execTraceCache size: %d", execTraceCacheSize)
var execTraceCache *lru.ARCCache[types.TipSetKey, tipSetCacheEntry] var execTraceCache *lru.ARCCache[types.TipSetKey, tipSetCacheEntry]
var err error var err error
if defaultExecTraceCacheSize > 0 { if execTraceCacheSize > 0 {
execTraceCache, err = lru.NewARC[types.TipSetKey, tipSetCacheEntry](defaultExecTraceCacheSize) execTraceCache, err = lru.NewARC[types.TipSetKey, tipSetCacheEntry](execTraceCacheSize)
if err != nil { if err != nil {
return nil, err return nil, err
} }