Commit d81cff3
Replace mruset setAddrKnown with CRollingBloomFilter addrKnown
Use a probabilistic bloom filter to keep track of which addresses
we think we have given our peers, instead of a list.
This uses much less memory, at the cost of sometimes failing to
relay an address to a peer-- worst case if the bloom filter happens
to be as full as it gets, 1-in-1,000.
Measured memory usage of a full mruset setAddrKnown: 650Kbytes
Constant memory usage of CRollingBloomFilter addrKnown: 37Kbytes.
This will also help heap fragmentation, because the 37K of storage
is allocated when a CNode is created (when a connection to a peer
is established) and then there is no per-item-remembered memory
allocation.
I plan on testing by restarting a full node with an empty peers.dat,
running a while with -debug=addrman and -debug=net, and making sure
that the 'addr' message traffic out is reasonable.
(suggestions for better tests welcome)1 parent 69a5f8b commit d81cff3
3 files changed
+9
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3995 | 3995 | | |
3996 | 3996 | | |
3997 | 3997 | | |
3998 | | - | |
| 3998 | + | |
3999 | 3999 | | |
4000 | 4000 | | |
4001 | 4001 | | |
| |||
4779 | 4779 | | |
4780 | 4780 | | |
4781 | 4781 | | |
4782 | | - | |
| 4782 | + | |
4783 | 4783 | | |
4784 | | - | |
| 4784 | + | |
4785 | 4785 | | |
4786 | 4786 | | |
4787 | 4787 | | |
| |||
4799 | 4799 | | |
4800 | 4800 | | |
4801 | 4801 | | |
4802 | | - | |
4803 | | - | |
| 4802 | + | |
4804 | 4803 | | |
| 4804 | + | |
4805 | 4805 | | |
4806 | 4806 | | |
4807 | 4807 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1905 | 1905 | | |
1906 | 1906 | | |
1907 | 1907 | | |
1908 | | - | |
| 1908 | + | |
1909 | 1909 | | |
1910 | 1910 | | |
1911 | 1911 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
| |||
0 commit comments