384 Commits

Author SHA1 Message Date
dependabot[bot]
7dc34b8068 build(deps): bump actions/checkout from 2 to 2.3.4
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 2.3.4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v2.3.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-12 06:21:55 +00:00
Pierre Krieger
5509775ce6 Merge pull request #112 from romanb/read-write-concurrent
Allow reads concurrent to pending writes.
2021-04-12 10:52:20 +02:00
Roman S. Borschel
96addec624 Small cleanup. 2021-02-23 18:30:14 +01:00
Roman S. Borschel
bb6cfa77fd Merge remote-tracking branch 'origin/read-write-concurrent' into read-write-concurrent 2021-02-23 18:21:20 +01:00
Roman Borschel
0102ce2038 Merge pull request #1 from mxinden/read-write-concurrent
src/connection: Remove Pausable wrapper around stream command
2021-02-23 18:18:05 +01:00
Max Inden
007f86da23 tests/concurrent: Vary both send and receive window size 2021-02-23 16:45:49 +01:00
Max Inden
a3b63b4852 tests/concurrent: Remove newline 2021-02-23 12:28:47 +01:00
Max Inden
912317e827 src/connection: Apply review suggestions 2021-02-23 12:13:11 +01:00
Max Inden
95167a639b tests/concurrent: Test with varying TCP send buffer sizes 2021-02-23 12:13:09 +01:00
Max Inden
34a7a9d17d src/connection: Remove Pausable wrapper around stream command 2021-02-22 13:25:04 +01:00
Roman S. Borschel
037f07098f Small test cleanup. 2021-02-22 10:48:41 +01:00
Roman S. Borschel
827ef8a6fb Small refinements. 2021-02-19 20:49:30 +01:00
Roman S. Borschel
ca5910ac44 Set maximum split-send-size for concurrent test. 2021-02-17 16:48:32 +01:00
Roman S. Borschel
99fb129162 Merge branch 'develop' into read-write-concurrent 2021-02-17 16:39:37 +01:00
Roman S. Borschel
a4f871fde9 Some more polishing. 2021-02-17 14:19:53 +01:00
Roman Borschel
22a7052ae7 Merge pull request #115 from romanb/v0.8.1
v0.8.1
2021-02-16 18:21:56 +01:00
Roman S. Borschel
0dd18122b6 Update github CI branches. 2021-02-16 16:07:17 +01:00
Roman S. Borschel
a003819b1b Backport a part of v0.9 2021-02-16 15:21:21 +01:00
Roman Borschel
0ddf9a33c1 Merge pull request #114 from romanb/v0.9
Prepare v0.9
2021-02-16 14:54:57 +01:00
Roman S. Borschel
eb6c732018 Implement Sink for Io. 2021-02-15 15:32:07 +01:00
Roman S. Borschel
5ae540b69d Prepare v0.9 2021-02-15 11:46:05 +01:00
Roman Borschel
9092eff3e8 Merge pull request #113 from paritytech/dependabot/cargo/env_logger-0.8
Update env_logger requirement from 0.6 to 0.8
2021-02-15 09:31:30 +01:00
dependabot[bot]
b7a8b694d7 Update env_logger requirement from 0.6 to 0.8
Updates the requirements on [env_logger](https://github.com/env-logger-rs/env_logger) to permit the latest version.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.6.0...v0.8.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-12 07:00:58 +00:00
Max Inden
29f50095d3 Merge pull request #111 from mxinden/split-data-frames
Limit data frame payload size
2021-02-11 17:19:06 +01:00
Roman S. Borschel
24d5464b25 Allow reads concurrent to pending writes.
Thereby propagate pending write back-pressure via the
paused command channels, rather than by "blocking"
`Connection::next()` itself until a write completes.

Notably, no new buffers are introduced. When a frame write
cannot complete, command channels are paused and I/O
reads can continue while the write is pending. The paused
command channels exercise write back-pressure on the streams
and API and ensure that the only frames we still try
to send are those as a result of reading a frame - these
then indeed wait for completion of the prior pending
send operation, if any, but since it is done as a result
of reading a frame, the remote can in turn write again,
should it have been waiting to be able to do so before
it in turn can read again. Unexpected write deadlocks
of peers which otherwise read & write concurrently
from substreams can thus be avoided.
2021-02-11 16:49:16 +01:00
Max Inden
4241ea416e Merge pull request #109 from mxinden/early-window-update
Send WindowUpdate message early
2021-02-11 16:38:02 +01:00
Roman Borschel
10f7ead0e9 Merge pull request #104 from romanb/test-write-deadlock
[tests] Add a test for a potential write deadlock.
2021-02-11 16:22:31 +01:00
Roman Borschel
c0b13ffc13 Merge branch 'develop' into test-write-deadlock 2021-02-11 16:19:10 +01:00
Max Inden
7a77cfbc66 src/lib: Make split_send_size configurable 2021-02-11 15:47:57 +01:00
Max Inden
8838373fad src: Limit data frame payload size
By limitting the data frame payload size one gains the following
beneftis:

1. Reduce delays sending time-sensitive frames, e.g. window updates.

2. Minimize head-of-line blocking across streams.

3. Enable better interleaving of send and receive operations, as each is
carried out atomically instead of concurrently with its respective
counterpart.

Limiting the frame size to 16KiB does not introduce a large overhead. A
Yamux frame header is 12 bytes large, thus this change introduces an
overhead of ~0.07%.
2021-02-10 21:06:13 +01:00
Max Inden
55db98a513 src/connection: Use eloquent doc comment for not resetting stream 2021-02-10 20:46:19 +01:00
Max Inden
d4398f0fa2 src/chunks: Track length instead of folding over each chunk 2021-02-10 20:43:26 +01:00
Max Inden
4b6a72ceac src/connection/stream: Continue reading when blocked on window update 2021-02-10 12:10:22 +01:00
Max Inden
439180c806 src/connection: Ignore frames from unknown streams
There are benign cases where frames from unknown streams can occur and
where a stream reset is not appropriate. See
https://github.com/paritytech/yamux/issues/110 for details.

This commit ignores frames from unknown streams for data, window update
and ping frames and adds documentation referencing back to issue #110.
2021-02-10 11:32:42 +01:00
dependabot[bot]
90720d796e Update rand requirement from 0.7.2 to 0.8.3 (#107)
Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-08 22:28:20 +01:00
dependabot[bot]
9cadf113f2 Update quickcheck requirement from 0.9 to 1.0 (#106)
* Update quickcheck requirement from 0.9 to 1.0

Updates the requirements on [quickcheck](https://github.com/BurntSushi/quickcheck) to permit the latest version.
- [Release notes](https://github.com/BurntSushi/quickcheck/releases)
- [Commits](https://github.com/BurntSushi/quickcheck/compare/quickcheck_macros-0.9.0...1.0.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-02-08 20:06:46 +01:00
Max Inden
df117583b7 src/connection/stream: Use saturating sub when calculating new window 2021-02-08 17:17:50 +01:00
Max Inden
faa0c91a11 src/connection/stream: Hold lock while sending window update
Hold lock for `Shared` long enough to prevent interleaved calls to
`next_window_update` possibly granting a receive window higher than the
configured one.
2021-02-08 16:56:18 +01:00
Max Inden
79f0905d55 src/connection: Do not check window when receiving and in OnRead
In `WindowUpdateMode::OnRead` one only grants the sender new credit once
existing bytes have been read. Thus there is no need to check whether to
send a new WindowUpdate message when receiving new bytes. One only needs
to check whether to send a new WindowUpdate message when reading bytes.
2021-02-08 16:42:40 +01:00
Max Inden
e56e0f60a1 src/connection: Send WindowUpdate message early
To prevent senders from being blocked every time they have sent
RECEIVE_WINDOW (e.g. 256 KB) number of bytes, waiting for a WindowUpdate
message granting further sending credit, this commit makes Yamux send a
WindowUpdate message once half or more of the window has been received
(and consumed in `WindowUpdateMode::OnRead`). Benchmarking shows that
sending WindowUpdate messages early prevents senders from being blocked
waiting for additional credit on common network types.

For a detailed discussion as well as various benchmark results see
https://github.com/paritytech/yamux/issues/100.

Next to the above, this commit includes the following changes:

- Use `WindowUpdateMode::OnRead` in benchmarks. I would argue that
`OnRead` should be the default setting, given the importance of
flow-control. With that in mind, I suggest to benchmark that default
case.

- Ignore WindowUpdate messages for unknown streams. With this commit
WindowUpdate messages are sent more agressively. The following scenario
would surface: A sender would close its channel, eventually being
garbage collected. The receiver, before receiving the closing message,
sends out a WindowUpdate message. The sender receives the WindowUpdate
message not being able to associate it to a stream, thus resetting the
whole connection. This commit ignores WindowUpdate messages for unknown
streams instead.

When sending very large messages, WindowUpdate messages are still not
returned to the sender in time, thus the sender still being blocked in
such case. This can be prevented by splitting large messages into
smaller Yamux frames, see
https://github.com/paritytech/yamux/issues/100#issuecomment-774461550.
This additional optimization can be done in a future commit without
interfering with the optimization introduced in this commit.
2021-02-08 16:30:07 +01:00
Roman Borschel
fb1122c0bf Update src/tests.rs
Co-authored-by: Max Inden <mail@max-inden.de>
2021-02-08 11:57:39 +01:00
Roman S. Borschel
2ed4150128 Small cleanup. 2021-02-08 11:56:38 +01:00
Roman Borschel
389415a3cd Merge pull request #103 from mxinden/add-dependabot
.github: Add dependabot
2021-02-04 16:36:02 +01:00
Roman S. Borschel
1182bd497c Add a test for a potential write deadlock.
The test is disabled for now, due to actually stalling.

As an aside, update tokio in the tests.
2021-02-04 16:08:04 +01:00
Max Inden
ae4745ebff .github: Add dependabot 2021-02-04 11:45:11 +01:00
Max Inden
dada223aa2 Merge pull request #102 from mxinden/bench-constrained-connection
benches: Benchmark with constrained connections
2021-02-03 14:29:16 +01:00
Max Inden
9e4297c3bb benches/concurrent: Remove unused imports 2021-02-03 14:16:02 +01:00
Max Inden
4674057366 benches/concurrent: Update doc comment 2021-02-03 14:14:22 +01:00
Max Inden
7eb4658f73 benches: Revert WindowUpdateMode back to OnReceive 2021-02-02 13:04:27 +01:00
Max Inden
054ce0ab1d benches: Benchmark with constrained connections
Previously the benchmarks would use an unbounded channel to simulate a
network connection. While this is helpful to measure the CPU impact of
Yamux specific changes, it is difficult to estimate how changes might
effect network throughput in different environments.

The crate `constrained-connection` can help simulate different
environments (DSL, HSDPA, GBit LAN, ...) by providing a channel
enforcing a specified bandwidth and delay. That said, it does not
simulate the OS network stack, routers, buffers, packet loss, ... Thus
as one would expect this can be used to detect trends, but not to e.g.
determine bandwidth expectations.

This commit makes the benchmarks run on top of a subset of the
connection types provided by `constrained-connection`. In addition it
retains the simulation on top of an unconstrained connection.

When simulating with low bandwidth-delay-product connections, yamux can
deadlock in the roundtrip scenario. Imagine a client sending a large
payload exceeding the bandwidth-delay-product of the connection to a
server. The server will try to echo the payload back to the client. Once
both client and server exhausted the buffer provided through the
bandwidth-delay-product of the connection, neither will be able to make
progress as the other won't read from the connection. This commit
rewrites the benchmarks, only having the client send to the server, but
not the server echoing back to the client.
2021-02-02 11:59:56 +01:00