Skip to content

Commit

Permalink
update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed May 23, 2023
1 parent 72d7351 commit 5e3e8e2
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 42 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Table Of Contents <!-- omit in toc -->
- [v0.28.0](#v0280)
- [v0.27.0](#v0270)
- [v0.26.4](#v0264)
- [v0.26.3](#v0263)
Expand All @@ -8,6 +9,17 @@
- [v0.25.1](#v0251)
- [v0.25.0](#v0250)

# [v0.28.0]()

## 🔦 Highlights <!-- omit in toc -->

### Smart Dialing <!-- omit in toc -->
* When connecting to a peer we now do [happy eyeballs](https://www.rfc-editor.org/rfc/rfc8305) like dial prioritisation to prefer QUIC addresses over TCP addresses. We dial the QUIC address first and wait 250ms to dial the TCP address of the peer.
* In our experiments we've seen little impact on latencies up to 80th percentile. 90th and 95th percentile latencies are impacted. For details see discussion on the [PR](https://github.com/libp2p/go-libp2p/pull/2260#issuecomment-1528848170).
* For details of the address ranking logic see godoc for `swarm.DefaultDialRanker`.
* To disable smart dialing and keep the old behaviour use the
`libp2p.NoDelayNetworkDialRanker` option.

# [v0.27.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.27.0)

### Breaking Changes <!-- omit in toc -->
Expand Down
3 changes: 2 additions & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ func PrometheusRegisterer(reg prometheus.Registerer) Option {
}
}

// NoDelayNetworkDialRanker configures libp2p to not delay any address while dialing
// NoDelayNetworkDialRanker configures libp2p to disable dial prioritisation and dial
// all addresses of the peer without any delay
func NoDelayNetworkDialRanker() Option {
return func(cfg *Config) error {
cfg.NoDelayNetworkDialRanker = true
Expand Down
35 changes: 17 additions & 18 deletions p2p/net/swarm/dial_ranker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ import (
// The 250ms value is from happy eyeballs RFC 8305. This is a rough estimate of 1 RTT
const (
// duration by which TCP dials are delayed relative to QUIC dial
publicTCPDelay = 250 * time.Millisecond
privateTCPDelay = 30 * time.Millisecond
PublicTCPDelay = 250 * time.Millisecond
PrivateTCPDelay = 30 * time.Millisecond

// duration by which QUIC dials are delayed relative to first QUIC dial
publicQUICDelay = 250 * time.Millisecond
privateQUICDelay = 30 * time.Millisecond
PublicQUICDelay = 250 * time.Millisecond
PrivateQUICDelay = 30 * time.Millisecond

// relayDelay is the duration by which relay dials are delayed relative to direct addresses
relayDelay = 250 * time.Millisecond
// RelayDelay is the duration by which relay dials are delayed relative to direct addresses
RelayDelay = 250 * time.Millisecond
)

// noDelayRanker ranks addresses with no delay. This is useful for simultaneous connect requests.
func noDelayRanker(addrs []ma.Multiaddr) []network.AddrDelay {
return getAddrDelay(addrs, 0, 0, 0)
}

// defaultDialRanker is the default ranking logic.
// DefaultDialRanker is the default ranking logic.
//
// We rank private, public ip4, public ip6, relay addresses separately.
// We do not prefer IPv6 over IPv4 as recommended by Happy Eyeballs RFC 8305. Currently there is no
Expand Down Expand Up @@ -58,12 +58,11 @@ func noDelayRanker(addrs []ma.Multiaddr) []network.AddrDelay {
// If a QUIC or webtransport address is present, TCP address dials are delayed by TCPDelay relative to
// the last QUIC dial.
//
// TCPDelay for public ip4 and public ip6 is publicTCPDelay
// TCPDelay for private addresses is privateTCPDelay
// QUICDelay for public addresses is publicQUICDelay
// QUICDelay for private addresses is privateQUICDelay
func defaultDialRanker(addrs []ma.Multiaddr) []network.AddrDelay {

// TCPDelay for public ip4 and public ip6 is PublicTCPDelay
// TCPDelay for private addresses is PrivateTCPDelay
// QUICDelay for public addresses is PublicQUICDelay
// QUICDelay for private addresses is PrivateQUICDelay
func DefaultDialRanker(addrs []ma.Multiaddr) []network.AddrDelay {
relay, addrs := filterAddrs(addrs, isRelayAddr)
pvt, addrs := filterAddrs(addrs, manet.IsPrivateAddr)
ip4, addrs := filterAddrs(addrs, func(a ma.Multiaddr) bool { return isProtocolAddr(a, ma.P_IP4) })
Expand All @@ -72,17 +71,17 @@ func defaultDialRanker(addrs []ma.Multiaddr) []network.AddrDelay {
var relayOffset time.Duration = 0
if len(ip4) > 0 || len(ip6) > 0 {
// if there is a public direct address available delay relay dials
relayOffset = relayDelay
relayOffset = RelayDelay
}

res := make([]network.AddrDelay, 0, len(addrs))
for i := 0; i < len(addrs); i++ {
res = append(res, network.AddrDelay{Addr: addrs[i], Delay: 0})
}
res = append(res, getAddrDelay(pvt, privateTCPDelay, privateQUICDelay, 0)...)
res = append(res, getAddrDelay(ip4, publicTCPDelay, publicQUICDelay, 0)...)
res = append(res, getAddrDelay(ip6, publicTCPDelay, publicQUICDelay, 0)...)
res = append(res, getAddrDelay(relay, publicTCPDelay, publicQUICDelay, relayOffset)...)
res = append(res, getAddrDelay(pvt, PrivateTCPDelay, PrivateQUICDelay, 0)...)
res = append(res, getAddrDelay(ip4, PublicTCPDelay, PublicQUICDelay, 0)...)
res = append(res, getAddrDelay(ip6, PublicTCPDelay, PublicQUICDelay, 0)...)
res = append(res, getAddrDelay(relay, PublicTCPDelay, PublicQUICDelay, relayOffset)...)
return res
}

Expand Down
44 changes: 22 additions & 22 deletions p2p/net/swarm/dial_ranker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,29 @@ func TestDelayRankerQUICDelay(t *testing.T) {
addrs: []ma.Multiaddr{q1, q2, q3, q4},
output: []network.AddrDelay{
{Addr: q1, Delay: 0},
{Addr: q2, Delay: publicQUICDelay},
{Addr: q3, Delay: publicQUICDelay},
{Addr: q4, Delay: publicQUICDelay},
{Addr: q2, Delay: PublicQUICDelay},
{Addr: q3, Delay: PublicQUICDelay},
{Addr: q4, Delay: PublicQUICDelay},
},
},
{
name: "quicv1 dialed before quic",
addrs: []ma.Multiaddr{q1, q2v1, q3, q4},
output: []network.AddrDelay{
{Addr: q2v1, Delay: 0},
{Addr: q1, Delay: publicQUICDelay},
{Addr: q3, Delay: publicQUICDelay},
{Addr: q4, Delay: publicQUICDelay},
{Addr: q1, Delay: PublicQUICDelay},
{Addr: q3, Delay: PublicQUICDelay},
{Addr: q4, Delay: PublicQUICDelay},
},
},
{
name: "quic+webtransport filtered when quicv1",
addrs: []ma.Multiaddr{q1, q2, q3, q4, q1v1, q2v1, q3v1, wt1},
output: []network.AddrDelay{
{Addr: q1v1, Delay: 0},
{Addr: q2v1, Delay: publicQUICDelay},
{Addr: q3v1, Delay: publicQUICDelay},
{Addr: q4, Delay: publicQUICDelay},
{Addr: q2v1, Delay: PublicQUICDelay},
{Addr: q3v1, Delay: PublicQUICDelay},
{Addr: q4, Delay: PublicQUICDelay},
},
},
{
Expand All @@ -118,14 +118,14 @@ func TestDelayRankerQUICDelay(t *testing.T) {
output: []network.AddrDelay{
{Addr: q1, Delay: 0},
{Addr: q1v16, Delay: 0},
{Addr: q2v16, Delay: publicQUICDelay},
{Addr: q3v16, Delay: publicQUICDelay},
{Addr: q2v16, Delay: PublicQUICDelay},
{Addr: q3v16, Delay: PublicQUICDelay},
},
},
}
for _, tc := range testCase {
t.Run(tc.name, func(t *testing.T) {
res := defaultDialRanker(tc.addrs)
res := DefaultDialRanker(tc.addrs)
if len(res) != len(tc.output) {
log.Errorf("expected %s got %s", tc.output, res)
t.Errorf("expected elems: %d got: %d", len(tc.output), len(res))
Expand Down Expand Up @@ -159,18 +159,18 @@ func TestDelayRankerTCPDelay(t *testing.T) {
addrs: []ma.Multiaddr{q1, q2v1, t1, t2},
output: []network.AddrDelay{
{Addr: q2v1, Delay: 0},
{Addr: q1, Delay: publicQUICDelay},
{Addr: t1, Delay: publicQUICDelay + publicTCPDelay},
{Addr: t2, Delay: publicQUICDelay + publicTCPDelay},
{Addr: q1, Delay: PublicQUICDelay},
{Addr: t1, Delay: PublicQUICDelay + PublicTCPDelay},
{Addr: t2, Delay: PublicQUICDelay + PublicTCPDelay},
},
},
{
name: "1 quic with tcp",
addrs: []ma.Multiaddr{q1, t1, t2},
output: []network.AddrDelay{
{Addr: q1, Delay: 0},
{Addr: t1, Delay: publicTCPDelay},
{Addr: t2, Delay: publicTCPDelay},
{Addr: t1, Delay: PublicTCPDelay},
{Addr: t2, Delay: PublicTCPDelay},
},
},
{
Expand All @@ -184,7 +184,7 @@ func TestDelayRankerTCPDelay(t *testing.T) {
}
for _, tc := range testCase {
t.Run(tc.name, func(t *testing.T) {
res := defaultDialRanker(tc.addrs)
res := DefaultDialRanker(tc.addrs)
if len(res) != len(tc.output) {
log.Errorf("expected %s got %s", tc.output, res)
t.Errorf("expected elems: %d got: %d", len(tc.output), len(res))
Expand Down Expand Up @@ -218,15 +218,15 @@ func TestDelayRankerRelay(t *testing.T) {
addrs: []ma.Multiaddr{q1, q2, r1, r2},
output: []network.AddrDelay{
{Addr: q1, Delay: 0},
{Addr: q2, Delay: publicQUICDelay},
{Addr: r2, Delay: relayDelay},
{Addr: r1, Delay: publicTCPDelay + relayDelay},
{Addr: q2, Delay: PublicQUICDelay},
{Addr: r2, Delay: RelayDelay},
{Addr: r1, Delay: PublicTCPDelay + RelayDelay},
},
},
}
for _, tc := range testCase {
t.Run(tc.name, func(t *testing.T) {
res := defaultDialRanker(tc.addrs)
res := DefaultDialRanker(tc.addrs)
if len(res) != len(tc.output) {
log.Errorf("expected %s got %s", tc.output, res)
t.Errorf("expected elems: %d got: %d", len(tc.output), len(res))
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func NewSwarm(local peer.ID, peers peerstore.Peerstore, eventBus event.Bus, opts
dialTimeout: defaultDialTimeout,
dialTimeoutLocal: defaultDialTimeoutLocal,
maResolver: madns.DefaultResolver,
dialRanker: defaultDialRanker,
dialRanker: DefaultDialRanker,
}

s.conns.m = make(map[peer.ID][]*Conn)
Expand Down

0 comments on commit 5e3e8e2

Please sign in to comment.