nim-libp2p/libp2p/stream
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
..
bufferstream.nim fix peer score accumulation (#541) 2021-03-09 13:22:52 +01:00
chronosstream.nim fix build with libp2p_agents_metrics switch 2021-03-15 01:42:47 +00:00
connection.nim Fix minor exception issues (#550) 2021-03-23 07:45:25 +01:00
lpstream.nim mem usage cleanups for pubsub (#564) 2021-04-18 10:08:33 +02:00
streamseq.nim logging fixes and small cleanups (#361) 2020-09-09 19:12:08 +02:00