mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-21 14:10:35 +02:00
lncfg+itest: expose configurable batch-commit-interval
This will permit a greater degree of tuning or customization depending on various hardware/environmental factors.
This commit is contained in:
@@ -275,6 +275,7 @@ func CreateWithBackend(backend kvdb.Backend, modifiers ...OptionModifier) (*DB,
|
||||
}
|
||||
chanDB.graph = newChannelGraph(
|
||||
chanDB, opts.RejectCacheSize, opts.ChannelCacheSize,
|
||||
opts.BatchCommitInterval,
|
||||
)
|
||||
|
||||
// Synchronize the version of database and apply migrations if needed.
|
||||
|
@@ -185,17 +185,18 @@ type ChannelGraph struct {
|
||||
|
||||
// newChannelGraph allocates a new ChannelGraph backed by a DB instance. The
|
||||
// returned instance has its own unique reject cache and channel cache.
|
||||
func newChannelGraph(db *DB, rejectCacheSize, chanCacheSize int) *ChannelGraph {
|
||||
func newChannelGraph(db *DB, rejectCacheSize, chanCacheSize int,
|
||||
batchCommitInterval time.Duration) *ChannelGraph {
|
||||
g := &ChannelGraph{
|
||||
db: db,
|
||||
rejectCache: newRejectCache(rejectCacheSize),
|
||||
chanCache: newChannelCache(chanCacheSize),
|
||||
}
|
||||
g.chanScheduler = batch.NewTimeScheduler(
|
||||
db.Backend, &g.cacheMu, 500*time.Millisecond,
|
||||
db.Backend, &g.cacheMu, batchCommitInterval,
|
||||
)
|
||||
g.nodeScheduler = batch.NewTimeScheduler(
|
||||
db.Backend, nil, 500*time.Millisecond,
|
||||
db.Backend, nil, batchCommitInterval,
|
||||
)
|
||||
return g
|
||||
}
|
||||
|
@@ -31,6 +31,10 @@ type Options struct {
|
||||
// channel cache.
|
||||
ChannelCacheSize int
|
||||
|
||||
// BatchCommitInterval is the maximum duration the batch schedulers will
|
||||
// wait before attempting to commit a pending set of updates.
|
||||
BatchCommitInterval time.Duration
|
||||
|
||||
// clock is the time source used by the database.
|
||||
clock clock.Clock
|
||||
|
||||
@@ -92,6 +96,14 @@ func OptionAutoCompactMinAge(minAge time.Duration) OptionModifier {
|
||||
}
|
||||
}
|
||||
|
||||
// OptionSetBatchCommitInterval sets the batch commit interval for the internval
|
||||
// batch schedulers.
|
||||
func OptionSetBatchCommitInterval(interval time.Duration) OptionModifier {
|
||||
return func(o *Options) {
|
||||
o.BatchCommitInterval = interval
|
||||
}
|
||||
}
|
||||
|
||||
// OptionClock sets a non-default clock dependency.
|
||||
func OptionClock(clock clock.Clock) OptionModifier {
|
||||
return func(o *Options) {
|
||||
|
Reference in New Issue
Block a user