nim-libp2p/libp2p
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
..
crypto Refactor minasn1 and fix security issues. (#323) 2020-08-11 16:58:51 -06:00
daemon simplify and unify logging (#353) 2020-09-06 10:31:47 +02:00
muxers refactor bufferstream to use a queue (#346) 2020-09-10 08:19:13 +02:00
protobuf Minprotobuf refactoring 2 (#269) 2020-07-15 10:25:39 +02:00
protocols refactor bufferstream to use a queue (#346) 2020-09-10 08:19:13 +02:00
stream refactor bufferstream to use a queue (#346) 2020-09-10 08:19:13 +02:00
transports Remove asyncCheck from codebase. (#345) 2020-09-04 18:30:45 +02:00
cid.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00
connmanager.nim logging fixes and small cleanups (#361) 2020-09-09 19:12:08 +02:00
errors.nim warn -> debug log levels in errors.nim 2020-08-20 16:53:28 +09:00
multiaddress.nim Minprotobuf refactoring 2 (#269) 2020-07-15 10:25:39 +02:00
multibase.nim add side effect annotations (#197) 2020-06-01 09:25:16 +02:00
multicodec.nim Crypto utilities resultification (#150) 2020-05-18 07:25:55 +02:00
multihash.nim add side effect annotations (#197) 2020-06-01 09:25:16 +02:00
multistream.nim logging fixes and small cleanups (#361) 2020-09-09 19:12:08 +02:00
peerid.nim simplify and unify logging (#353) 2020-09-06 10:31:47 +02:00
peerinfo.nim simplify and unify logging (#353) 2020-09-06 10:31:47 +02:00
standard_setup.nim Rework pubsub (#322) 2020-08-11 18:05:49 -06:00
switch.nim logging fixes and small cleanups (#361) 2020-09-09 19:12:08 +02:00
transcoder.nim add side effect annotations (#197) 2020-06-01 09:25:16 +02:00
utility.nim Less verbose traces (#112) 2020-03-23 15:03:36 +09:00
varint.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00
vbuffer.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00
wire.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00