mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
rpc: optimize DescribeGraph by caching the response
Unfortunately, we can't use the graph cache directly here as it doesn't include all the information we need, since it only includes the minimal amount of information needed for path finding. Instead, we use a simple mutex guarded cache that evicts itself after a certain interval. The default is set small enough that most users shouldn't really notice. We also provide a way to disable the cache, and also disable the cache in the itests. Fixes https://github.com/lightningnetwork/lnd/issues/1232
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package lncfg
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// MinRejectCacheSize is a floor on the maximum capacity allowed for
|
||||
@@ -10,6 +13,10 @@ const (
|
||||
// MinChannelCacheSize is a floor on the maximum capacity allowed for
|
||||
// channeldb's channel cache. This amounts to roughly 2 MB when full.
|
||||
MinChannelCacheSize = 1000
|
||||
|
||||
// DefaultRPCGraphCacheDuration is the default interval that the RPC
|
||||
// response to DescribeGraph should be cached for.
|
||||
DefaultRPCGraphCacheDuration = time.Minute
|
||||
)
|
||||
|
||||
// Caches holds the configuration for various caches within lnd.
|
||||
@@ -24,6 +31,10 @@ type Caches struct {
|
||||
// peers querying for gossip traffic. Memory usage is roughly 2Kb per
|
||||
// entry.
|
||||
ChannelCacheSize int `long:"channel-cache-size" description:"Maximum number of entries contained in the channel cache, which is used to reduce memory allocations from gossip queries from peers. Each entry requires roughly 2Kb."`
|
||||
|
||||
// RPCGraphCacheDuration is used to control the flush interval of the
|
||||
// channel graph cache.
|
||||
RPCGraphCacheDuration time.Duration `long:"rpc-graph-cache-duration" description:"The period of time expressed as a duration (1s, 1m, 1h, etc) that the RPC response to DescribeGraph should be cached for."`
|
||||
}
|
||||
|
||||
// Validate checks the Caches configuration for values that are too small to be
|
||||
|
Reference in New Issue
Block a user