From 4e8ee737fcbf67f155b085b0bd019de391ce3bc0 Mon Sep 17 00:00:00 2001 From: Fridrik Asmundsson Date: Thu, 4 May 2023 17:10:26 +0000 Subject: [PATCH 1/2] Address review comments --- chain/stmgr/execute.go | 4 ++-- chain/stmgr/stmgr.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/chain/stmgr/execute.go b/chain/stmgr/execute.go index 09fdb6fd0..bed857833 100644 --- a/chain/stmgr/execute.go +++ b/chain/stmgr/execute.go @@ -131,7 +131,7 @@ func (sm *StateManager) ExecutionTrace(ctx context.Context, ts *types.TipSet) (c tsKey := ts.Key() // check if we have the trace for this tipset in the cache - if defaultExecTraceCacheSize > 0 { + if execTraceCacheSize > 0 { sm.execTraceCacheLock.Lock() if entry, ok := sm.execTraceCache.Get(tsKey); ok { // 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 } - if defaultExecTraceCacheSize > 0 { + if execTraceCacheSize > 0 { invocTraceCopy := makeDeepCopy(invocTrace) sm.execTraceCacheLock.Lock() diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 224c63ddb..12b991e57 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -42,7 +42,7 @@ import ( const LookbackNoLimit = api.LookbackNoLimit const ReceiptAmtBitwidth = 3 -var defaultExecTraceCacheSize = 16 +var execTraceCacheSize = 16 var log = logging.Logger("statemgr") type StateManagerAPI interface { @@ -76,12 +76,12 @@ func (m *migrationResultCache) keyForMigration(root cid.Cid) dstore.Key { } 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) 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 { - 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 err error - if defaultExecTraceCacheSize > 0 { - execTraceCache, err = lru.NewARC[types.TipSetKey, tipSetCacheEntry](defaultExecTraceCacheSize) + if execTraceCacheSize > 0 { + execTraceCache, err = lru.NewARC[types.TipSetKey, tipSetCacheEntry](execTraceCacheSize) if err != nil { return nil, err } From 171f1f716ad3f9c0a4b17c38a99daee5950b5511 Mon Sep 17 00:00:00 2001 From: Fridrik Asmundsson Date: Thu, 4 May 2023 17:50:25 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 500f41619..17cf7a8c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 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 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.