mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 06:55:13 +01:00
gossipd: don't keep channel_announcement messages in memory.
MCP results from 5 runs, min-max(mean +/- stddev): store_load_msec:35107-37944(36686+/-1e+03) vsz_kb:1218036 store_rewrite_sec:14.060000-17.970000(15.966+/-1.6) listnodes_sec:1.270000-1.350000(1.314+/-0.034) listchannels_sec:28.510000-30.270000(29.6+/-0.6) routing_sec:30.230000-31.510000(30.83+/-0.44) peer_write_all_sec:67.390000-70.710000(68.568+/-1.2) MCP notable changes from previous patch (>1 stddev): -vsz_kb:1780516 +vsz_kb:1218036 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
2fd4a0121f
commit
3280466e19
4 changed files with 13 additions and 12 deletions
|
@ -174,7 +174,7 @@ static bool add_local_unnannounced(int fd,
|
|||
const u8 *msg;
|
||||
|
||||
/* Ignore already announced. */
|
||||
if (c->channel_announce)
|
||||
if (is_chan_public(c))
|
||||
continue;
|
||||
|
||||
msg = towire_gossipd_local_add_channel(tmpctx, &c->scid,
|
||||
|
|
|
@ -1112,7 +1112,7 @@ static void maybe_create_next_scid_reply(struct peer *peer)
|
|||
if (!chan || !is_chan_public(chan))
|
||||
continue;
|
||||
|
||||
queue_peer_msg(peer, chan->channel_announce);
|
||||
queue_peer_from_store(peer, &chan->bcast);
|
||||
if (chan->half[0].channel_update)
|
||||
queue_peer_msg(peer, chan->half[0].channel_update);
|
||||
if (chan->half[1].channel_update)
|
||||
|
|
|
@ -424,7 +424,6 @@ struct chan *new_chan(struct routing_state *rstate,
|
|||
chan->nodes[n1idx] = n1;
|
||||
chan->nodes[!n1idx] = n2;
|
||||
chan->txout_script = NULL;
|
||||
chan->channel_announce = NULL;
|
||||
broadcastable_init(&chan->bcast);
|
||||
chan->sat = satoshis;
|
||||
chan->local_disabled = false;
|
||||
|
@ -917,14 +916,14 @@ static bool is_local_channel(const struct routing_state *rstate,
|
|||
|
||||
static void add_channel_announce_to_broadcast(struct routing_state *rstate,
|
||||
struct chan *chan,
|
||||
const u8 *channel_announce,
|
||||
u32 timestamp,
|
||||
u32 index)
|
||||
{
|
||||
chan->bcast.timestamp = timestamp;
|
||||
/* 0, unless we're loading from store */
|
||||
chan->bcast.index = index;
|
||||
insert_broadcast(&rstate->broadcasts, chan->channel_announce,
|
||||
&chan->bcast);
|
||||
insert_broadcast(&rstate->broadcasts, channel_announce, &chan->bcast);
|
||||
rstate->local_channel_announced |= is_local_channel(rstate, chan);
|
||||
}
|
||||
|
||||
|
@ -950,6 +949,9 @@ bool routing_add_channel_announcement(struct routing_state *rstate,
|
|||
if (taken(msg))
|
||||
tal_steal(tmpctx, msg);
|
||||
|
||||
if (taken(msg))
|
||||
tal_steal(tmpctx, msg);
|
||||
|
||||
if (!fromwire_channel_announcement(
|
||||
tmpctx, msg, &node_signature_1, &node_signature_2,
|
||||
&bitcoin_signature_1, &bitcoin_signature_2, &features, &chain_hash,
|
||||
|
@ -1427,15 +1429,17 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
|||
* receiving the first corresponding `channel_update`.
|
||||
*/
|
||||
if (uc) {
|
||||
chan->channel_announce = tal_steal(chan, uc->channel_announce);
|
||||
add_channel_announce_to_broadcast(rstate, chan, timestamp,
|
||||
add_channel_announce_to_broadcast(rstate, chan,
|
||||
uc->channel_announce,
|
||||
timestamp,
|
||||
uc->index);
|
||||
} else if (!chan->channel_announce) {
|
||||
} else if (!is_chan_public(chan)) {
|
||||
/* For private channels, we get updates without an announce: don't
|
||||
* broadcast them! But save local ones to store anyway. */
|
||||
struct half_chan *hc = &chan->half[direction];
|
||||
/* Don't save if we're loading from store */
|
||||
if (is_local_channel(rstate, chan) && !index) {
|
||||
assert(is_local_channel(rstate, chan));
|
||||
if (!index) {
|
||||
hc->bcast.index = gossip_store_add(rstate->broadcasts->gs,
|
||||
hc->channel_update);
|
||||
} else
|
||||
|
|
|
@ -52,9 +52,6 @@ struct chan {
|
|||
/* node[0].id < node[1].id */
|
||||
struct node *nodes[2];
|
||||
|
||||
/* NULL if not announced yet (ie. not public). */
|
||||
const u8 *channel_announce;
|
||||
|
||||
/* Timestamp and index into store file */
|
||||
struct broadcastable bcast;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue