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

multi: replace per channel sigPool with global daemon level sigPool #2329

Merged
merged 1 commit into from
Dec 18, 2018

Conversation

Roasbeef
Copy link
Member

In this commit, we remove the per channel sigPool within the
lnwallet.LightningChannel struct. With this change, we ensure that as
the number of channels grows, the number of gouroutines idling in the
sigPool stays constant. It's the case that currently on the daemon, most
channels are likely inactive, with only a hand full actually
consistently carrying out channel updates. As a result, this change
should reduce the amount of idle CPU usage, as we have less active
goroutines in select loops.

In order to make this change, the SigPool itself has been publicly
exported such that outside callers can make a SigPool and pass it into
newly created channels. Since the sig pool now lives outside the
channel, we were also able to do away with the Stop() method on the
channel all together.

Finally, the server is the sub-system that is currently responsible for
managing the SigPool within lnd.

@Roasbeef Roasbeef added wallet The wallet (lnwallet) which LND uses channels P3 might get fixed, nice to have needs review PR needs review by regular contributors optimization labels Dec 15, 2018
@@ -1467,18 +1459,6 @@ func (lc *LightningChannel) createStateHintObfuscator() {
}
}

// Stop gracefully shuts down any active goroutines spawned by the
// LightningChannel during regular duties.
func (lc *LightningChannel) Stop() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: looks like we can also remove the now unused shutdown and quit members.

@cfromknecht
Copy link
Contributor

breacharbiter_test doesn't compile atm

# github.com/lightningnetwork/lnd [github.com/lightningnetwork/lnd.test]
./breacharbiter_test.go:1573:43: undefined: bobPool

In this commit, we remove the per channel `sigPool` within the
`lnwallet.LightningChannel` struct. With this change, we ensure that as
the number of channels grows, the number of gouroutines idling in the
sigPool stays constant. It's the case that currently on the daemon, most
channels are likely inactive, with only a hand full actually
consistently carrying out channel updates. As a result, this change
should reduce the amount of idle CPU usage, as we have less active
goroutines in select loops.

In order to make this change, the `SigPool` itself has been publicly
exported such that outside callers can make a `SigPool` and pass it into
newly created channels. Since the sig pool now lives outside the
channel, we were also able to do away with the Stop() method on the
channel all together.

Finally, the server is the sub-system that is currently responsible for
managing the `SigPool` within lnd.
@Roasbeef
Copy link
Member Author

Fixed, PTAL!

Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this on my testnet node and confirmed this reduced the amount of goroutines from one per channel to one globally. LGTM 🎯

@Roasbeef Roasbeef merged commit 152fc8b into lightningnetwork:master Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channels needs review PR needs review by regular contributors optimization P3 might get fixed, nice to have wallet The wallet (lnwallet) which LND uses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants