Skip to content

Commit

Permalink
chore: add relay
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 11, 2024
1 parent a44f101 commit e5c6814
Show file tree
Hide file tree
Showing 13 changed files with 1,263 additions and 376 deletions.
15 changes: 4 additions & 11 deletions perf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,21 @@ Given you have provisioned your infrastructure, you can now build and run the li
- For a new version of an existing implementation, create a folder `impl/<your-implementation-name>/<your-implementation-version>`.
- 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 circuit relay server:
- The relay server must not exit as it will be closed by the test runner.
- Input via command line
- `--role relay`
- `--external-ip` the external IP the container is reachable on
- `--listen-port` the port to listen on
- The relay server should write the multiaddr it is dialable on to stdout
- Running as a libp2p-perf server:
- 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.
- Input via command line
- `--role listener`
- `--external-ip` the external IP the container is reachable on
- `--listen-port` the port to listen on
- `--relay-address` if a relay was started as part of the test run, this is the multiadr it is listening on
- `--transport` (see [`runner/versions.ts`](./runner/src/versions.ts#L7-L43) for possible variants)
- `--platform` optionally specify what to run the code on (browsers, electron, etc)
- The listener should write the multiaddr it is dialable on to stdout
- The server should write the multiaddr it is dialable on to stdout to populate the `--server-address` option passed to the client
- If it does not `--server-address` will be set to a `host_ip:host_port` pair for the server
- 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
- `--role dialer`
- `--listener-address` the multiaddr to dial to reach the listener
- `--server-address` the multiaddr to dial to reach the server
- `--transport` (see [`runner/versions.ts`](./runner/src/versions.ts#L7-L43) for possible variants)
- `--upload-bytes` number of bytes to upload per stream.
- `--download-bytes` number of bytes to download per stream.
Expand Down
108 changes: 0 additions & 108 deletions perf/impl/js-libp2p/v1.0-webrtc-16kb/index.js

This file was deleted.

12 changes: 5 additions & 7 deletions perf/impl/js-libp2p/v1.0-webrtc-16kb/perf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cleanup() {
}
trap cleanup EXIT TERM

role=""
role="dialer"
platform=""

# Parse named parameters manually
Expand All @@ -21,7 +21,7 @@ for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--relay-address" ]; then
export RELAY_ADDRESS="${@:i+1:1}"
fi
if [ "${!i}" == "--listener-address" ]; then
if [ "${!i}" == "--server-address" ]; then
export LISTENER_ADDRESS="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
Expand All @@ -33,8 +33,8 @@ for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--transport" ]; then
export TRANSPORT="${@:i+1:1}"
fi
if [ "${!i}" == "--role" ]; then
role="${@:i+1:1}"
if [ "${!i}" == "--run-server" ]; then
role="listener"
fi
if [ "${!i}" == "--platform" ]; then
platform="${@:i+1:1}"
Expand All @@ -44,9 +44,7 @@ done
cd $(dirname "$0")

# start something
if [ "${role}" == "relay" ]; then
node relay.js &
elif [ "${role}" == "listener" ]; then
if [ "${role}" == "listener" ]; then
if [ "${platform}" == "chromium" ] || [ "${platform}" == "firefox" ] || [ "${platform}" == "webkit" ]; then
if [ $RELAY_ADDRESS == "" ]; then
echo ERROR: a relay address is required to run a browser listener 1>&2
Expand Down
108 changes: 0 additions & 108 deletions perf/impl/js-libp2p/v1.0-webrtc-256kb/index.js

This file was deleted.

12 changes: 5 additions & 7 deletions perf/impl/js-libp2p/v1.0-webrtc-256kb/perf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cleanup() {
}
trap cleanup EXIT TERM

role=""
role="dialer"
platform=""

# Parse named parameters manually
Expand All @@ -21,7 +21,7 @@ for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--relay-address" ]; then
export RELAY_ADDRESS="${@:i+1:1}"
fi
if [ "${!i}" == "--listener-address" ]; then
if [ "${!i}" == "--server-address" ]; then
export LISTENER_ADDRESS="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
Expand All @@ -33,8 +33,8 @@ for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--transport" ]; then
export TRANSPORT="${@:i+1:1}"
fi
if [ "${!i}" == "--role" ]; then
role="${@:i+1:1}"
if [ "${!i}" == "--run-server" ]; then
role="listener"
fi
if [ "${!i}" == "--platform" ]; then
platform="${@:i+1:1}"
Expand All @@ -44,9 +44,7 @@ done
cd $(dirname "$0")

# start something
if [ "${role}" == "relay" ]; then
node relay.js &
elif [ "${role}" == "listener" ]; then
if [ "${role}" == "listener" ]; then
if [ "${platform}" == "chromium" ] || [ "${platform}" == "firefox" ] || [ "${platform}" == "webkit" ]; then
if [ $RELAY_ADDRESS == "" ]; then
echo ERROR: a relay address is required to run a browser listener 1>&2
Expand Down
39 changes: 0 additions & 39 deletions perf/impl/js-libp2p/v1.0-webrtc-256kb/relay.js

This file was deleted.

9 changes: 9 additions & 0 deletions perf/relay/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
all: relay

relay:
npm ci

clean:
rm -rf node_modules

.PHONY: all clean relay
Loading

0 comments on commit e5c6814

Please sign in to comment.