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

chore: fvm: update FFI to not arbitrary limit FVM concurrency #11867

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ There is no change in the behaviour when a call returns an error, as the error o

## New features

### FVM RPC Concurrent Requests

The default maximum FVM concurrency (`LOTUS_FVM_CONCURRENCY`) has increased from 4 to the number of available CPU threads. Furthermore, the FVM now allocates `LOTUS_FVM_CONCURRENCY` OS-level threads with 64MiB stacks (in 1.26, we allocated one thread per CPU core regardless of the value of `LOTUS_FVM_CONCURRENCY`).

Impact:

1. This will increase memory usage for nodes specifying a higher `LOTUS_FVM_CONCURRENCY` than the number of CPU threads they have available.
2. This will allow such nodes to actually take advantage of this higher concurrency limit where the concurrency was previously capped at the number of available CPU threads.


## Improvements

# v1.27.0 / 2024-05-27
Expand Down
20 changes: 10 additions & 10 deletions chain/vm/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package vm
import (
"context"
"os"
"runtime"
"strconv"
"sync"

Expand All @@ -14,16 +15,15 @@ import (
"github.com/filecoin-project/lotus/metrics"
)

const (
// DefaultAvailableExecutionLanes is the number of available execution lanes; it is the bound of
// concurrent active executions.
// This is the default value in filecoin-ffi
DefaultAvailableExecutionLanes = 4
// DefaultPriorityExecutionLanes is the number of reserved execution lanes for priority computations.
// This is purely userspace, but we believe it is a reasonable default, even with more available
// lanes.
DefaultPriorityExecutionLanes = 2
)
// DefaultPriorityExecutionLanes is the number of reserved execution lanes for priority computations.
// This is purely userspace, but we believe it is a reasonable default, even with more available
// lanes.
const DefaultPriorityExecutionLanes = 2

// DefaultAvailableExecutionLanes is the number of available execution lanes; it is the bound of
// concurrent active executions.
// This is the default value in filecoin-ffi
var DefaultAvailableExecutionLanes = runtime.NumCPU()

// the execution environment; see below for definition, methods, and initialization
var execution *executionEnv
Expand Down
15 changes: 11 additions & 4 deletions node/modules/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,20 @@ func CheckFvmConcurrency() func(al *alerting.Alerting) {
return
}

// Raise alert if LOTUS_FVM_CONCURRENCY is set to a high value
if fvmConcurrencyVal > 24 {
if fvmConcurrencyVal < 2 {
alert := al.AddAlertType("process", "fvm-concurrency")
al.Raise(alert, map[string]interface{}{
"message": "LOTUS_FVM_CONCURRENCY is set to a high value that can cause chain sync panics on network migrations/upgrades",
"message": "LOTUS_FVM_CONCURRENCY should be at least 2",
"set_value": fvmConcurrencyVal,
"recommended": "24 or less during network upgrades",
"recommended": "set it to two or more",
})
}
if fvmConcurrencyVal > 512 {
alert := al.AddAlertType("process", "fvm-concurrency")
al.Raise(alert, map[string]interface{}{
"message": "LOTUS_FVM_CONCURRENCY is set to a high value that can cause chain sync panics on network migrations/upgrades and excessive memory usage (>32GiB)",
"set_value": fvmConcurrencyVal,
"recommended": "leave it unset to default to the number of available cpu threads",
})
}
}
Expand Down