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

10585 address review comments #10827

Merged
merged 2 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions chain/stmgr/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
14 changes: 7 additions & 7 deletions chain/stmgr/stmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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
}
Expand Down