diff --git a/routing/router.go b/routing/router.go index b308338a6..0cb0ced8e 100644 --- a/routing/router.go +++ b/routing/router.go @@ -3,6 +3,7 @@ package routing import ( "bytes" "fmt" + "runtime" "sync" "sync/atomic" "time" @@ -914,7 +915,28 @@ func (r *ChannelRouter) networkHandler() { // We'll use this validation barrier to ensure that we process all jobs // in the proper order during parallel validation. - validationBarrier := NewValidationBarrier(1000, r.quit) + // + // NOTE: For AssumeChannelValid, we bump up the maximum number of + // concurrent validation requests since there are no blocks being + // fetched. This significantly increases the performance of IGD for + // neutrino nodes. + // + // However, we dial back to use multiple of the number of cores when + // fully validating, to avoid fetching up to 1000 blocks from the + // backend. On bitcoind, this will empirically cause massive latency + // spikes when executing this many concurrent RPC calls. Critical + // subsystems or basic rpc calls that rely on calls such as GetBestBlock + // will hang due to excessive load. + // + // See https://github.com/lightningnetwork/lnd/issues/4892. + var validationBarrier *ValidationBarrier + if r.cfg.AssumeChannelValid { + validationBarrier = NewValidationBarrier(1000, r.quit) + } else { + validationBarrier = NewValidationBarrier( + 4*runtime.NumCPU(), r.quit, + ) + } for {