docs+lncfg+sample-lnd.conf: add no-graph-cache option

This commit is contained in:
Oliver Gugger 2021-10-21 13:55:18 +02:00
parent cac8da819f
commit a2ad533136
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
3 changed files with 49 additions and 22 deletions

View File

@ -92,6 +92,14 @@ usage. Users running `lnd` on low-memory systems are advised to run with the
removes zombie channels from the graph, reducing the number of channels that
need to be kept in memory.
There is a [fallback option](https://github.com/lightningnetwork/lnd/pull/5840)
`db.no-graph-cache=true` that can be used when running a Bolt (`bbolt`) based
database backend. Using the database for path finding is considerably slower
than using the in-memory graph cache but uses less RAM. The fallback option is
not available for `etcd` or Postgres database backends because of the way they
handle long-running database transactions that are required for the path finding
operations.
## Protocol Extensions
### Explicit Channel Negotiation

View File

@ -57,6 +57,8 @@ type DB struct {
Bolt *kvdb.BoltConfig `group:"bolt" namespace:"bolt" description:"Bolt settings."`
Postgres *postgres.Config `group:"postgres" namespace:"postgres" description:"Postgres settings."`
NoGraphCache bool `long:"no-graph-cache" description:"Don't use the in-memory graph cache for path finding. Much slower but uses less RAM. Can only be used with a bolt database backend."`
}
// DefaultDB creates and returns a new default DB config.
@ -87,8 +89,21 @@ func (db *DB) Validate() error {
}
default:
return fmt.Errorf("unknown backend, must be either \"%v\" or \"%v\"",
BoltBackend, EtcdBackend)
return fmt.Errorf("unknown backend, must be either '%v' or "+
"'%v'", BoltBackend, EtcdBackend)
}
// The path finding uses a manual read transaction that's open for a
// potentially long time. That works fine with the locking model of
// bbolt but can lead to locks or rolled back transactions with etcd or
// postgres. And since we already have a smaller memory footprint for
// remote database setups (due to not needing to memory-map the bbolt DB
// files), we can keep the graph in memory instead. But for mobile
// devices the tradeoff between a smaller memory footprint and the
// longer time needed for path finding might be a desirable one.
if db.NoGraphCache && db.Backend != BoltBackend {
return fmt.Errorf("cannot use no-graph-cache with database "+
"backend '%v'", db.Backend)
}
return nil

View File

@ -1118,6 +1118,9 @@ litecoin.node=ltcd
; a batch of modifications to disk. Defaults to 500 milliseconds.
; db.batch-commit-interval=500ms
; Don't use the in-memory graph cache for path finding. Much slower but uses
; less RAM. Can only be used with a bolt database backend.
; db.no-graph-cache=true
[etcd]
@ -1170,6 +1173,27 @@ litecoin.node=ltcd
; disable.
; db.postgres.timeout=
[bolt]
; If true, prevents the database from syncing its freelist to disk.
; db.bolt.nofreelistsync=1
; Whether the databases used within lnd should automatically be compacted on
; every startup (and if the database has the configured minimum age). This is
; disabled by default because it requires additional disk space to be available
; during the compaction that is freed afterwards. In general compaction leads to
; smaller database files.
; db.bolt.auto-compact=true
; How long ago the last compaction of a database file must be for it to be
; considered for auto compaction again. Can be set to 0 to compact on every
; startup. (default: 168h)
; db.bolt.auto-compact-min-age=0
; Specify the timeout to be used when opening the database.
; db.bolt.dbtimeout=60s
[cluster]
; Enables leader election if set.
@ -1217,26 +1241,6 @@ litecoin.node=ltcd
; The TLS certificate to use for establishing the remote signer's identity.
; remotesigner.tlscertpath=/path/to/remote/signer/tls.cert
[bolt]
; If true, prevents the database from syncing its freelist to disk.
; db.bolt.nofreelistsync=1
; Whether the databases used within lnd should automatically be compacted on
; every startup (and if the database has the configured minimum age). This is
; disabled by default because it requires additional disk space to be available
; during the compaction that is freed afterwards. In general compaction leads to
; smaller database files.
; db.bolt.auto-compact=true
; How long ago the last compaction of a database file must be for it to be
; considered for auto compaction again. Can be set to 0 to compact on every
; startup. (default: 168h)
; db.bolt.auto-compact-min-age=0
; Specify the timeout to be used when opening the database.
; db.bolt.dbtimeout=60s
[gossip]