Address review comments
This commit is contained in:
parent
c940f597a4
commit
4e8ee737fc
@ -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()
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user