nim-libp2p/tests/pubsub
Jacek Sieka e285d8bbf4
mem usage cleanups for pubsub (#564)
In `async` functions, a closure environment is created for variables
that cross an await boundary - this closure environment is kept in
memory for the lifetime of the associated future - this means that
although _some_ variables are no longer used, they still take up memory
for a long time.

In Nimbus, message validation is processed in batches meaning the future
of an incoming gossip message stays around for quite a while - this
leads to memory consumption peaks of 100-200 mb when there are many
attestations in the pipeline.

To avoid excessive memory usage, it's generally better to move non-async
code into proc's such that the variables therein can be released earlier
- this includes the many hidden variables introduced by macro and
template expansion (ie chronicles that does expensive exception
handling)

* move seen table salt to floodsub, use there as well
* shorten seen table salt to size of hash
* avoid unnecessary memory allocations and copies in a few places
* factor out message scoring
* avoid reencoding outgoing message for every peer
* keep checking validators until reject (in case there's both reject and
ignore)
* `readOnce` avoids `readExactly` overhead for single-byte read
* genericAssign -> assign2
2021-04-18 10:08:33 +02:00
..
testfloodsub.nim Revisit Floodsub (#543) 2021-03-15 13:16:03 -06:00
testgossipinternal.nim use a builder pattern to build the switch (#551) 2021-04-02 10:20:51 +09:00
testgossipsub.nim mem usage cleanups for pubsub (#564) 2021-04-18 10:08:33 +02:00
testmcache.nim gossipsub / floodsub fixes (#348) 2020-09-04 08:10:32 +02:00
testmessage.nim allow to omit peerId and seqno (#372) 2020-09-23 17:56:33 +02:00
testpubsub.nim gossipsub / floodsub fixes (#348) 2020-09-04 08:10:32 +02:00
testtimedcache.nim fix poor performance in LRU cache (#360) 2020-09-09 18:28:46 +02:00
utils.nim use a builder pattern to build the switch (#551) 2021-04-02 10:20:51 +09:00