Backfill gossip without buffering directly in LDK
authorMatt Corallo <git@bluematt.me>
Tue, 9 Aug 2022 21:26:16 +0000 (21:26 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 15 Aug 2022 21:35:05 +0000 (21:35 +0000)
commit7717fa23a8cccdd31afa086f5c2487e9ba90bbfc
treea6a24aa58060d3be62ca811b07c0a91611c8704e
parent4f6da92c4e1f42259fbc01aee1812a2fdd9d8638
Backfill gossip without buffering directly in LDK

Instead of backfilling gossip by buffering (up to) ten messages at
a time, only buffer one message at a time, as the peers' outbound
socket buffer drains. This moves the outbound backfill messages out
of `PeerHandler` and into the operating system buffer, where it
arguably belongs.

Not buffering causes us to walk the gossip B-Trees somewhat more
often, but avoids allocating vecs for the responses. While its
probably (without having benchmarked it) a net performance loss, it
simplifies buffer tracking and leaves us with more room to play
with the buffer sizing constants as we add onion message forwarding
which is an important win.

Note that because we change how often we check if we're out of
messages to send before pinging, we slightly change how many
messages are exchanged at once, impacting the
`test_do_attempt_write_data` constants.
lightning-net-tokio/src/lib.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/msgs.rs
lightning/src/ln/peer_handler.rs
lightning/src/routing/gossip.rs
lightning/src/util/test_utils.rs