fix(perf): re-introduce js-libp2p + add encryption (#299)

This commit is contained in:
Chad Nehemiah 2023-09-14 11:49:46 -05:00 committed by GitHub
parent b8235c9eae
commit a96d930eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1822 additions and 1366 deletions

View File

@ -52,7 +52,7 @@ Given you have provisioned your infrastructure, you can now build and run the li
1. `cd runner`
2. `npm ci`
3. `npm run start -- --client-public-ip $CLIENT_IP --server-public-ip $SERVER_IP`
3. `npm run start -- --client-public-ip $CLIENT_IP --server-public-ip $SERVER_IP`
* Note: The default number of iterations that perf will run is 10; desired iterations can be set with the `--iterations <value>` option.
### Deprovision infrastructure

View File

@ -2,8 +2,9 @@ GO_SUBDIRS := $(wildcard go-libp2p/*/.)
RUST_SUBDIRS := $(wildcard rust-libp2p/*/.)
HTTPS_SUBDIRS := $(wildcard https/*/.)
QUIC_GO_SUBDIRS := $(wildcard quic-go/*/.)
JS_SUBDIRS := $(wildcard js-libp2p/*/.)
all: $(RUST_SUBDIRS) $(GO_SUBDIRS) $(HTTPS_SUBDIRS) $(QUIC_GO_SUBDIRS)
all: $(RUST_SUBDIRS) $(GO_SUBDIRS) $(HTTPS_SUBDIRS) $(QUIC_GO_SUBDIRS) $(JS_SUBDIRS)
$(RUST_SUBDIRS):
$(MAKE) -C $@
$(GO_SUBDIRS):
@ -12,10 +13,12 @@ $(HTTPS_SUBDIRS):
$(MAKE) -C $@
$(QUIC_GO_SUBDIRS):
$(MAKE) -C $@
$(JS_SUBDIRS):
$(MAKE) -C $@
clean: $(RUST_SUBDIRS:%=%clean) $(GO_SUBDIRS:%=%clean) $(HTTPS_SUBDIRS:%=%clean) $(QUIC_GO_SUBDIRS:%=%clean)
clean: $(RUST_SUBDIRS:%=%clean) $(GO_SUBDIRS:%=%clean) $(HTTPS_SUBDIRS:%=%clean) $(QUIC_GO_SUBDIRS:%=%clean) $(JS_SUBDIRS:%=%clean)
%clean:
$(MAKE) -C $* clean
.PHONY: $(RUST_SUBDIRS) $(GO_SUBDIRS) $(HTTPS_SUBDIRS) $(QUIC_GO_SUBDIRS) all clean
.PHONY: $(RUST_SUBDIRS) $(GO_SUBDIRS) $(HTTPS_SUBDIRS) $(QUIC_GO_SUBDIRS) $(JS_SUBDIRS) all clean

3
perf/impl/js-libp2p/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
js-libp2p-*.zip
js-libp2p-*
js-libp2p-*/*

View File

@ -0,0 +1,19 @@
NPM_PACKAGE_VERSION := 1.1.6
NPM_PACKAGE := @libp2p/perf
NPM_PACKAGE_NAME := $(NPM_PACKAGE)@$(NPM_PACKAGE_VERSION)
SOURCE_DIR := js-libp2p-protocol-perf
DOCKER_IMAGE := node:18.17.1
DOCKER_RUN := docker run --rm -v "$(shell pwd)/$(SOURCE_DIR)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
mkdir -p $(SOURCE_DIR)
$(DOCKER_RUN) npm install $(NPM_PACKAGE_NAME)
clean:
rm -rf js-libp2p-*
.PHONY: all clean perf

45
perf/impl/js-libp2p/v0.46/perf Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node impl/js-libp2p/v0.46/js-libp2p-protocol-perf/node_modules/@libp2p/perf/dist/src/main.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid

File diff suppressed because it is too large Load Diff

View File

@ -35,4 +35,9 @@ export const versions: Array<Version> = [
implementation: "go-libp2p",
transportStacks: ["tcp", "quic-v1"]
},
{
id: "v0.46",
implementation: "js-libp2p",
transportStacks: ["tcp"]
}
]