nim-libp2p/libp2p/protocols/pubsub
Jacek Sieka 96d4c44fec
refactor bufferstream to use a queue (#346)
This change modifies how the backpressure algorithm in bufferstream
works - in particular, instead of working byte-by-byte, it will now work
seq-by-seq.

When data arrives, it usually does so in packets - in the current
bufferstream, the packet is read then split into bytes which are fed one
by one to the bufferstream. On the reading side, the bytes are popped of
the bufferstream, again byte by byte, to satisfy `readOnce` requests -
this introduces a lot of synchronization traffic because the checks for
full buffer and for async event handling must be done for every byte.

In this PR, a queue of length 1 is used instead - this means there will
at most exist one "packet" in `pushTo`, one in the queue and one in the
slush buffer that is used to store incomplete reads.

* avoid byte-by-byte copy to buffer, with synchronization in-between
* reuse AsyncQueue synchronization logic instead of rolling own
* avoid writeHandler callback - implement `write` method instead
* simplify EOF signalling by only setting EOF flag in queue reader (and
reset)
* remove BufferStream pipes (unused)
* fixes drainBuffer deadlock when drain is called from within read loop
and thus blocks draining
* fix lpchannel init order
2020-09-10 08:19:13 +02:00
..
rpc simplify and unify logging (#353) 2020-09-06 10:31:47 +02:00
floodsub.nim simplify and unify logging (#353) 2020-09-06 10:31:47 +02:00
gossipsub.nim simplify and unify logging (#353) 2020-09-06 10:31:47 +02:00
mcache.nim gossipsub / floodsub fixes (#348) 2020-09-04 08:10:32 +02:00
peertable.nim small cleanups & docs (#347) 2020-09-04 18:31:43 +02:00
pubsub.nim simplify and unify logging (#353) 2020-09-06 10:31:47 +02:00
pubsubpeer.nim refactor bufferstream to use a queue (#346) 2020-09-10 08:19:13 +02:00
timedcache.nim fix poor performance in LRU cache (#360) 2020-09-09 18:28:46 +02:00