Skip to content

Commit

Permalink
Merge pull request #2642 from fetchai/fix/libp2p_slow_dht_lookups
Browse files Browse the repository at this point in the history
libp2p: fix for slow dht lookups using extra queue
  • Loading branch information
5A11 authored Dec 14, 2021
2 parents f164977 + cf55072 commit bc78738
Show file tree
Hide file tree
Showing 11 changed files with 553 additions and 199 deletions.
2 changes: 1 addition & 1 deletion libs/go/libp2p_node/dht/dhtclient/dhtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/rs/zerolog"
"google.golang.org/protobuf/proto"

"github.com/libp2p/go-libp2p"
libp2p "github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
Expand Down
6 changes: 5 additions & 1 deletion libs/go/libp2p_node/dht/dhtpeer/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ package dhtpeer

import (
"bufio"
"context"
"flag"
"net"
"os"
"testing"
"time"

"libp2p_node/acn"
"libp2p_node/aea"
Expand Down Expand Up @@ -330,10 +332,12 @@ func benchmarkAgentLookup(npeers uint16, b *testing.B) {
}
defer peerCleanup()
ensureAddressAnnounced(peer)
ctx, cancel_lookup := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel_lookup()

for i := 0; i < b.N; i++ {
b.ResetTimer()
_, _, err = peer.lookupAddressDHT(addrs[len(peers)-1-i%len(peers)])
_, _, err = peer.lookupAddressDHT(ctx, addrs[len(peers)-1-i%len(peers)])
if err != nil {
b.Fail()
}
Expand Down
Loading

0 comments on commit bc78738

Please sign in to comment.