lightningd: use hash map for peers instead of linked list.

After connecting 100,000 peers with one channel each (not all at
once!), we see various places where we exhibit O(N^2) behaviour.

Fix these by keeping a map of id->peer instead of a simple
linked-list.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-01-18 15:34:32 +10:30
committed by Alex Myers
parent 17aa047b17
commit cfa632b0e9
11 changed files with 143 additions and 51 deletions

View File

@@ -155,6 +155,7 @@ static void finish_report(const struct leak_detect *leaks)
memleak_scan_htable(memtable, &ld->htlcs_in->raw);
memleak_scan_htable(memtable, &ld->htlcs_out->raw);
memleak_scan_htable(memtable, &ld->htlc_sets->raw);
memleak_scan_htable(memtable, &ld->peers->raw);
/* Now delete ld and those which it has pointers to. */
memleak_scan_obj(memtable, ld);