Skip to content

Conversation

ucwong
Copy link
Member

@ucwong ucwong commented May 31, 2021

This change significantly improves the performance of RLPx message reads
and writes. In the previous implementation, reading and writing of
message frames performed multiple reads and writes on the underlying
network connection, and allocated a new []byte buffer for every read.

In the new implementation, reads and writes re-use buffers, and perform
much fewer system calls on the underlying connection. This doubles the
theoretically achievable throughput on a single connection, as shown by
the benchmark result:

name             old speed      new speed       delta
Throughput-8     70.3MB/s ± 0%  155.4MB/s ± 0%  +121.11%  (p=0.000 n=9+8)

The change also removes support for the legacy, pre-EIP-8 handshake encoding.
As of May 2021, no actively maintained client sends this format.

This change significantly improves the performance of RLPx message reads
and writes. In the previous implementation, reading and writing of
message frames performed multiple reads and writes on the underlying
network connection, and allocated a new []byte buffer for every read.

In the new implementation, reads and writes re-use buffers, and perform
much fewer system calls on the underlying connection. This doubles the
theoretically achievable throughput on a single connection, as shown by
the benchmark result:

    name             old speed      new speed       delta
    Throughput-8     70.3MB/s ± 0%  155.4MB/s ± 0%  +121.11%  (p=0.000 n=9+8)

The change also removes support for the legacy, pre-EIP-8 handshake encoding.
As of May 2021, no actively maintained client sends this format.
@codecov
Copy link

codecov bot commented May 31, 2021

Codecov Report

Merging #964 (d4d789b) into master (bfa75c9) will increase coverage by 0.06%.
The diff coverage is 80.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #964      +/-   ##
==========================================
+ Coverage   49.15%   49.21%   +0.06%     
==========================================
  Files         423      424       +1     
  Lines       47236    47270      +34     
==========================================
+ Hits        23217    23265      +48     
+ Misses      22009    21988      -21     
- Partials     2010     2017       +7     
Impacted Files Coverage Δ
p2p/rlpx/rlpx.go 63.36% <75.75%> (+1.80%) ⬆️
p2p/rlpx/buffer.go 89.47% <89.47%> (ø)
p2p/transport.go 80.88% <100.00%> (+0.28%) ⬆️
rlp/raw.go 85.00% <100.00%> (+6.01%) ⬆️
rpc/server.go 71.05% <0.00%> (-5.27%) ⬇️
ctxc/downloader/statesync.go 56.20% <0.00%> (-4.27%) ⬇️
rpc/client.go 83.52% <0.00%> (-1.18%) ⬇️
p2p/simulations/network.go 57.57% <0.00%> (-0.87%) ⬇️
p2p/simulations/http.go 66.02% <0.00%> (-0.65%) ⬇️
ctxc/downloader/downloader.go 76.13% <0.00%> (-0.12%) ⬇️
... and 8 more

@ucwong ucwong merged commit a3637ef into master May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants