File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
lightning-background-processor/src Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -203,10 +203,22 @@ impl BackgroundProcessor {
203203 let mut have_pruned = false ;
204204
205205 loop {
206- peer_manager. process_events ( ) ; // Note that this may block on ChannelManager's locking
207206 channel_manager. process_pending_events ( & event_handler) ;
208207 chain_monitor. process_pending_events ( & event_handler) ;
209208
209+ // Note that the PeerManager::process_events may block on ChannelManager's locks,
210+ // hence it comes last here. When the ChannelManager finishes whatever it's doing,
211+ // we want to ensure we get into `persist_manager` as quickly as we can, especially
212+ // without running the normal event processing above and handing events to users.
213+ //
214+ // Specifically, on an *extremely* slow machine, we may see ChannelManager start
215+ // processing a message effectively at any point during this loop. In order to
216+ // minimize the time between such processing completing and persisting the updated
217+ // ChannelManager, we want to minimize methods blocking on a ChannelManager
218+ // generally, and as a fallback place such blocking only immediately before
219+ // persistence.
220+ peer_manager. process_events ( ) ;
221+
210222 // We wait up to 100ms, but track how long it takes to detect being put to sleep,
211223 // see `await_start`'s use below.
212224 let await_start = Instant :: now ( ) ;
You can’t perform that action at this time.
0 commit comments