Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9db3c75
feat: test ws/noise/tls
achingbrain Mar 4, 2025
3d75f12
chore: print address
achingbrain Mar 10, 2025
fac0d7a
chore: print address
achingbrain Mar 10, 2025
ada0530
chore: ensure there is output
achingbrain Mar 10, 2025
3f3ae8e
chore: restore pid wait
achingbrain Mar 10, 2025
2ed75b8
chore: just run node
achingbrain Mar 10, 2025
122c41c
chore: restore iterations
achingbrain Mar 10, 2025
b564134
chore: print server logs when no ma found
achingbrain Mar 12, 2025
517125e
chore: print server logs when client fails
achingbrain Mar 13, 2025
9f12638
chore: do not exit process
achingbrain Mar 13, 2025
3d4a118
chore: increase max age
achingbrain Mar 13, 2025
4153820
chore: timeouts
achingbrain Mar 14, 2025
a1379e1
chore: update js
achingbrain Mar 14, 2025
25b3bf5
chore: timeouts
achingbrain Mar 14, 2025
16cd8ab
Merge remote-tracking branch 'origin/master' into feat/test-more-tran…
achingbrain Mar 14, 2025
eb82112
chore: remove timeout
achingbrain Mar 14, 2025
40a5f43
chore: reduce iterations
achingbrain Mar 14, 2025
0cc580a
chore: reduce impls
achingbrain Mar 14, 2025
63cab6d
chore: increase timeout
achingbrain Mar 14, 2025
8720a6a
Merge branch 'master' into feat/test-more-transports
achingbrain Mar 14, 2025
0c51ff6
chore: ignore webrtc-direct
achingbrain Mar 14, 2025
9dbf6d2
perf: update benchmark results
achingbrain Mar 14, 2025
d28ebc6
chore: restore iterations
achingbrain Mar 14, 2025
40f8b07
perf: update benchmark results
achingbrain Mar 14, 2025
c705850
chore: revert property rename
achingbrain Apr 14, 2025
c20930f
chore: update readme
achingbrain Apr 14, 2025
9970180
chore: no esm
achingbrain Apr 14, 2025
131faeb
chore: unfix go
achingbrain Apr 14, 2025
826ff56
chore: split
achingbrain Apr 14, 2025
ec52b53
chore: go again
achingbrain Apr 14, 2025
30a693c
chore: remove unused var
achingbrain Apr 14, 2025
813ffbe
fix: use native encryption
achingbrain Apr 14, 2025
400c9d7
chore: log errors before exit
achingbrain Apr 14, 2025
8d620bc
chore: remove logging
achingbrain Apr 14, 2025
760aec4
Merge branch 'master' of https://github.com/libp2p/test-plans into fe…
p-shahi Jun 9, 2025
ecc720b
re-add missing v2.0 files
p-shahi Jun 9, 2025
e52d572
fix go
p-shahi Jun 10, 2025
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
15 changes: 12 additions & 3 deletions perf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ Given you have provisioned your infrastructure, you can now build and run the li
- In that folder include a `Makefile` that builds an executable and stores it next to the `Makefile` under the name `perf`.
- Requirements for the executable:
- Running as a libp2p-perf server:
- Input via command line
- `--run-server` this flag is passed without a value
- `--server-address` an IPv4 socket address to listen on (e.g. `0.0.0.0:4001`) - the port can be used as TCP or UDP and should be used with the specified transport as appropriate
- `--transport` (see [`runner/versions.ts`](./runner/src/versions.ts) for possible variants)
- `--encryption` (see [`runner/versions.ts`](./runner/src/versions.ts) for possible variants)
- The perf server must not exit as it will be closed by the test runner.
- The executable must accept the command flag `--run-server` which indicates it's running as server.
- It should print any multiaddrs that it is listening on to STDOUT, including the `/p2p/$PEER_ID` tuple and any ephemeral information such as cert hashes
- The first address will be selected & the host/port replaced with values mapped publicly to the container
- The updated address will be passed to the perf client as the `--server-address` argument
- If it does not do this (legacy), the socket address will be passed instead
- Running as a libp2p-perf client
- Given that perf is a client driven set of benchmarks, the performance will be measured by the client.
- Input via command line
- `--server-address`
- `--transport` (see [`runner/versions.ts`](./runner/src/versions.ts#L7-L43) for possible variants)
- `--server-address` either the updated multiaddr (see libp2p-perf server section above) or a `host:port` socket address
- `--transport` (see [`runner/versions.ts`](./runner/src/versions.ts) for possible variants)
- `--encryption` (see [`runner/versions.ts`](./runner/src/versions.ts) for possible variants)
- `--upload-bytes` number of bytes to upload per stream.
- `--download-bytes` number of bytes to download per stream.
- Output
Expand Down
43 changes: 20 additions & 23 deletions perf/impl/go-libp2p/v0.41/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,32 @@ import (

func main() {
runServer := flag.Bool("run-server", false, "Should run as server")
serverAddr := flag.String("server-address", "", "Server address")
serverAddr := flag.String("server-address", "0.0.0.0:4001", "Server address")
transport := flag.String("transport", "tcp", "Transport to use")
uploadBytes := flag.Uint64("upload-bytes", 0, "Upload bytes")
downloadBytes := flag.Uint64("download-bytes", 0, "Download bytes")
flag.Parse()

host, port, err := net.SplitHostPort(*serverAddr)
if err != nil {
log.Fatal(err)
}

tcpMultiAddrStr := fmt.Sprintf("/ip4/%s/tcp/%s", host, port)
quicMultiAddrStr := fmt.Sprintf("/ip4/%s/udp/%s/quic-v1", host, port)

var opts []libp2p.Option
if *runServer {
opts = append(opts, libp2p.ListenAddrStrings(tcpMultiAddrStr, quicMultiAddrStr))
host, port, err := net.SplitHostPort(*serverAddr)
if err != nil {
log.Fatal(err)
}

tcpMultiAddrStr := fmt.Sprintf("/ip4/%s/tcp/%s", host, port)
quicMultiAddrStr := fmt.Sprintf("/ip4/%s/udp/%s/quic-v1", host, port)

switch *transport {
case "tcp":
opts = append(opts, libp2p.ListenAddrStrings(tcpMultiAddrStr))
case "quic-v1":
opts = append(opts, libp2p.ListenAddrStrings(quicMultiAddrStr))
default:
fmt.Println("Invalid transport. Accepted values: 'tcp' or 'quic-v1'")
return
}

// Generate stable fake identity.
//
// Using a stable identity (i.e. peer ID) allows the client to
Expand Down Expand Up @@ -62,19 +71,7 @@ func main() {
select {} // run forever, exit on interrupt
}

var multiAddrStr string
switch *transport {
case "tcp":
multiAddrStr = tcpMultiAddrStr
case "quic-v1":
multiAddrStr = quicMultiAddrStr
default:
fmt.Println("Invalid transport. Accepted values: 'tcp' or 'quic-v1'")
return
}
// Peer ID corresponds to the above fake identity.
multiAddrStr = multiAddrStr + "/p2p/12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN"
serverInfo, err := peer.AddrInfoFromString(multiAddrStr)
serverInfo, err := peer.AddrInfoFromString(*serverAddr)
if err != nil {
log.Fatalf("failed to build address info: %s", err)
}
Expand Down
12 changes: 12 additions & 0 deletions perf/impl/js-libp2p/v1.0/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:22
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)

all: perf

perf:
$(DOCKER_RUN) npm ci

clean:
rm -rf node_modules

.PHONY: all clean perf
136 changes: 136 additions & 0 deletions perf/impl/js-libp2p/v1.0/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { parseArgs } from 'node:util'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { perf } from '@libp2p/perf'
import { tcp } from '@libp2p/tcp'
import { webSockets } from '@libp2p/websockets'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'

process.on('uncaughtException', (err) => {
console.error('Uncaught exception', err.stack ?? err)
process.exit(1)
})

process.on('unhandledRejection', (err) => {
console.error('Unhandled rejection', err.stack ?? err)
process.exit(1)
})

const argv = parseArgs({
options: {
'run-server': {
type: 'boolean',
default: false
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
encryption: {
type: 'string',
default: 'noise'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})

/**
* @param {boolean} runServer
* @param {string} serverAddress
* @param {string} transport
* @param {string} encryption
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverAddress, transport, encryption, uploadBytes, downloadBytes) {
const config = {
addresses: {},
transports: [],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
services: {
perf: perf()
}
}

if (transport === 'tcp') {
config.transports = [
tcp()
]
} else if (transport === 'ws') {
config.transports = [
webSockets()
]
}

if (runServer) {
const { host, port } = splitHostPort(serverAddress)

if (transport === 'tcp') {
config.addresses.listen = [
`/ip4/${host}/tcp/${port}`
]
} else if (transport === 'ws') {
config.addresses.listen = [
`/ip4/${host}/tcp/${port}/ws`
]
}
}

const node = await createLibp2p(config)

if (runServer) {
// print our multiaddr (may have certhashes in it)
for (const addr of node.getMultiaddrs()) {
console.error(addr.toString())
}
} else {
const serverMa = multiaddr(serverAddress)

for await (const output of node.services.perf.measurePerformance(serverMa, uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}

await node.stop()
}
}

/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}

main(argv.values['run-server'], argv.values['server-address'], argv.values.transport, argv.values.encryption, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
Loading
Loading