Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions benchmarks/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ import (
"github.com/ipld/go-ipld-prime/node/basicnode"
ipldselector "github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
protocol "github.com/libp2p/go-libp2p/core/protocol"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"

"github.com/ipfs/go-graphsync/benchmarks/testinstance"
tn "github.com/ipfs/go-graphsync/benchmarks/testnet"
graphsync "github.com/ipfs/go-graphsync/impl"
gsmsg "github.com/ipfs/go-graphsync/message"
gsmsgv2 "github.com/ipfs/go-graphsync/message/v2"
gsnet "github.com/ipfs/go-graphsync/network"
tn "github.com/ipfs/go-protocolnetwork/pkg/testnet"
)

type runStats struct {
Expand Down Expand Up @@ -78,7 +82,8 @@ func BenchmarkRoundtripSuccess(b *testing.B) {
func benchmarkRepeatedDisconnects(ctx context.Context, b *testing.B, numnodes int, df distFunc, tdm *tempDirMaker) {
ctx, cancel := context.WithCancel(ctx)
mn := mocknet.New()
net := tn.StreamNet(ctx, mn)
net, err := tn.StreamNet[gsmsg.GraphSyncMessage](ctx, "graphsync", []protocol.ID{gsnet.ProtocolGraphsync_2_0_0}, gsnet.NewMessageHandlerSelector(), mn)
require.NoError(b, err)
ig := testinstance.NewTestInstanceGenerator(ctx, net, nil, tdm, false)
instances, err := ig.Instances(numnodes + 1)
require.NoError(b, err)
Expand Down Expand Up @@ -147,7 +152,8 @@ func p2pStrestTest(ctx context.Context, b *testing.B, numfiles int, df distFunc,
defer cancel()
mn := mocknet.New()
mn.SetLinkDefaults(mocknet.LinkOptions{Latency: 100 * time.Millisecond, Bandwidth: 3000000})
net := tn.StreamNet(ctx, mn)
net, err := tn.StreamNet[gsmsg.GraphSyncMessage](ctx, "graphsync", []protocol.ID{gsnet.ProtocolGraphsync_2_0_0}, gsnet.NewMessageHandlerSelector(), mn)
require.NoError(b, err)
ig := testinstance.NewTestInstanceGenerator(ctx, net, options, tdm, diskBasedDatastore)
instances, err := ig.Instances(1 + b.N)
require.NoError(b, err)
Expand Down Expand Up @@ -198,7 +204,7 @@ func p2pStrestTest(ctx context.Context, b *testing.B, numfiles int, df distFunc,
func subtestDistributeAndFetch(ctx context.Context, b *testing.B, numnodes int, d delay.D, bstoreLatency time.Duration, df distFunc, tdm *tempDirMaker) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
net := tn.VirtualNetwork(d)
net := tn.VirtualNetwork[gsmsg.GraphSyncMessage](d, []protocol.ID{gsnet.ProtocolGraphsync_2_0_0}, gsmsgv2.NewMessageHandler())
ig := testinstance.NewTestInstanceGenerator(ctx, net, nil, tdm, false)
instances, err := ig.Instances(numnodes + b.N)
require.NoError(b, err)
Expand Down
9 changes: 5 additions & 4 deletions benchmarks/testinstance/testinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (
badgerds "github.com/ipfs/go-ds-badger"
blockstore "github.com/ipfs/go-ipfs-blockstore"
delay "github.com/ipfs/go-ipfs-delay"
tn "github.com/ipfs/go-protocolnetwork/pkg/testnet"
"github.com/ipld/go-ipld-prime"
tnet "github.com/libp2p/go-libp2p-testing/net"
p2ptestutil "github.com/libp2p/go-libp2p-testing/netutil"
peer "github.com/libp2p/go-libp2p/core/peer"

graphsync "github.com/ipfs/go-graphsync"
tn "github.com/ipfs/go-graphsync/benchmarks/testnet"
gsimpl "github.com/ipfs/go-graphsync/impl"
gsmsg "github.com/ipfs/go-graphsync/message"
gsnet "github.com/ipfs/go-graphsync/network"
"github.com/ipfs/go-graphsync/storeutil"
)
Expand All @@ -29,7 +30,7 @@ type TempDirGenerator interface {

// NewTestInstanceGenerator generates a new InstanceGenerator for the given
// testnet
func NewTestInstanceGenerator(ctx context.Context, net tn.Network, gsOptions []gsimpl.Option, tempDirGenerator TempDirGenerator, diskBasedDatastore bool) InstanceGenerator {
func NewTestInstanceGenerator(ctx context.Context, net tn.Network[gsmsg.GraphSyncMessage], gsOptions []gsimpl.Option, tempDirGenerator TempDirGenerator, diskBasedDatastore bool) InstanceGenerator {
ctx, cancel := context.WithCancel(ctx)
return InstanceGenerator{
net: net,
Expand All @@ -45,7 +46,7 @@ func NewTestInstanceGenerator(ctx context.Context, net tn.Network, gsOptions []g
// InstanceGenerator generates new test instances of bitswap+dependencies
type InstanceGenerator struct {
seq int
net tn.Network
net tn.Network[gsmsg.GraphSyncMessage]
ctx context.Context
cancel context.CancelFunc
gsOptions []gsimpl.Option
Expand Down Expand Up @@ -139,7 +140,7 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
// NB: It's easy make mistakes by providing the same peer ID to two different
// instances. To safeguard, use the InstanceGenerator to generate instances. It's
// just a much better idea.
func NewInstance(ctx context.Context, net tn.Network, p tnet.Identity, gsOptions []gsimpl.Option, tempDir string, diskBasedDatastore bool) (Instance, error) {
func NewInstance(ctx context.Context, net tn.Network[gsmsg.GraphSyncMessage], p tnet.Identity, gsOptions []gsimpl.Option, tempDir string, diskBasedDatastore bool) (Instance, error) {
bsdelay := delay.Fixed(0)

adapter := net.Adapter(p)
Expand Down
15 changes: 0 additions & 15 deletions benchmarks/testnet/interface.go

This file was deleted.

63 changes: 0 additions & 63 deletions benchmarks/testnet/internet_latency_delay_generator.go

This file was deleted.

63 changes: 0 additions & 63 deletions benchmarks/testnet/internet_latency_delay_generator_test.go

This file was deleted.

106 changes: 0 additions & 106 deletions benchmarks/testnet/network_test.go

This file was deleted.

43 changes: 0 additions & 43 deletions benchmarks/testnet/peernet.go

This file was deleted.

Loading