Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Aug 28, 2023
0 parents commit 94a98c1
Show file tree
Hide file tree
Showing 60 changed files with 4,815 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: daily

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
50 changes: 50 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI
on:
pull_request:
push:
branches:
- main

jobs:
autobahn:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: nightly-2023-08-01
- uses: Swatinem/rust-cache@v2

- run: .scripts/autobahn.sh ci

# fuzz:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions-rs/toolchain@v1
# with:
# override: true
# profile: minimal
# toolchain: nightly-2023-08-01
# - uses: actions-rs/[email protected]
# with:
# crate: cargo-fuzz
# use-tool-cache: true
#
# - run: .scripts/fuzz.sh

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
components: clippy, rustfmt
override: true
profile: minimal
toolchain: nightly-2023-08-01
- uses: Swatinem/rust-cache@v2

- run: .scripts/wtx.sh
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.scripts/autobahn/reports
.vscode
**/*.rs.bk
**/artifacts
**/Cargo.lock
**/corpus
**/target
**/target
47 changes: 47 additions & 0 deletions .scripts/autobahn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
set -euxo pipefail

ARG=${1:-""}
if [ "$ARG" != "ci" ]; then
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
fi;

# fuzzingclient

cargo build --example web_socket_server_echo_raw_tokio --features tokio,web-socket-handshake --release
cargo run --example web_socket_server_echo_raw_tokio --features tokio,web-socket-handshake --release & cargo_pid=$!
mkdir -p .scripts/autobahn/reports/fuzzingclient
podman run \
-v .scripts/autobahn/fuzzingclient.json:/fuzzingclient.json:ro \
-v .scripts/autobahn:/autobahn \
--name fuzzingclient \
--net=host \
--rm \
docker.io/crossbario/autobahn-testsuite:0.8.2 wstest -m fuzzingclient -s fuzzingclient.json
podman rm --force --ignore fuzzingclient
kill -9 $cargo_pid

if [ $(grep -ci "failed" .scripts/autobahn/reports/fuzzingclient/index.json) -gt 0 ]
then
exit 1
fi

## fuzzingserver

cargo build --example web_socket_client_autobahn_raw_tokio --features tokio,web-socket-handshake --release
mkdir -p .scripts/autobahn/reports/fuzzingserver
podman run \
-d \
-p 9080:9080 \
-v .scripts/autobahn/fuzzingserver.json:/fuzzingserver.json:ro \
-v .scripts/autobahn:/autobahn \
--name fuzzingserver \
--net=host \
docker.io/crossbario/autobahn-testsuite:0.8.2 wstest -m fuzzingserver -s fuzzingserver.json
sleep 5
cargo run --example web_socket_client_autobahn_raw_tokio --features tokio,web-socket-handshake --release -- 127.0.0.1:9080
podman rm --force --ignore fuzzingserver

if [ $(grep -ci "failed" .scripts/autobahn/reports/fuzzingserver/index.json) -gt 0 ]
then
exit 1
fi
12 changes: 12 additions & 0 deletions .scripts/autobahn/fuzzingclient.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"cases": ["1.*", "2.*", "3.*", "4.*", "5.*", "6.*", "7.*", "9.*", "10.*"],
"exclude-agent-cases": {},
"exclude-cases": [],
"outdir": "/autobahn/reports/fuzzingclient",
"servers": [
{
"agent": "wtx",
"url": "ws://127.0.0.1:8080"
}
]
}
7 changes: 7 additions & 0 deletions .scripts/autobahn/fuzzingserver.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"cases": ["1.*", "2.*", "3.*", "4.*", "5.*", "6.*", "7.*", "9.*", "10.*"],
"exclude-agent-cases": {},
"exclude-cases": [],
"outdir": "/autobahn/reports/fuzzingserver",
"url": "ws://127.0.0.1:9080"
}
9 changes: 9 additions & 0 deletions .scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euxo pipefail

export rt='cargo run --bin rust-tools -- --template you-rust'

export CARGO_TARGET_DIR="$($rt target-dir)"
export RUST_BACKTRACE=1
export RUSTFLAGS="$($rt rust-flags)"
6 changes: 6 additions & 0 deletions .scripts/fuzz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -euxo pipefail

cargo fuzz run --fuzz-dir wtx-fuzz unmask -- -runs=100000
cargo fuzz run --fuzz-dir wtx-fuzz parse-frame -- -runs=100000
60 changes: 60 additions & 0 deletions .scripts/wtx-bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

set -euxo pipefail

trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT

pushd /tmp
git clone https://github.com/c410-f3r/fastwebsockets || true
cd fastwebsockets
git checkout -t origin/bench || true
RUSTFLAGS='-C target-cpu=native' cargo build --example echo_server --features simd,upgrade --release
RUSTFLAGS='-C target-cpu=native' cargo run --example echo_server --features simd,upgrade --release 127.0.0.1:8080 &

cd /tmp
git clone https://github.com/c410-f3r/websocket || true
cd websocket/examples/echo
git checkout -t origin/bench || true
go run server.go 127.0.0.1:8081 &

cd /tmp
git clone https://github.com/c410-f3r/tokio-tungstenite || true
cd tokio-tungstenite
git checkout -t origin/bench || true
RUSTFLAGS='-C target-cpu=native' cargo build --example echo-server --release
RUSTFLAGS='-C target-cpu=native' cargo run --example echo-server --release 127.0.0.1:8082 &

cd /tmp
git clone --recursive https://github.com/c410-f3r/uWebSockets.git || true
cd uWebSockets
git checkout -t origin/bench || true
if [ ! -e ./EchoServer ]
then
make examples
fi
./EchoServer 8083 &
popd

RUSTFLAGS='-C target-cpu=native' cargo build --example web_socket_server_echo_hyper --features simdutf8,web-socket-hyper --release
RUSTFLAGS='-C target-cpu=native' cargo run --example web_socket_server_echo_hyper --features simdutf8,web-socket-hyper --release 127.0.0.1:8084 &

RUSTFLAGS='-C target-cpu=native' cargo build --example web_socket_server_echo_raw_async_std --features async-std,simdutf8,web-socket-handshake --release
RUSTFLAGS='-C target-cpu=native' cargo run --example web_socket_server_echo_raw_async_std --features async-std,simdutf8,web-socket-handshake --release 127.0.0.1:8085 &

RUSTFLAGS='-C target-cpu=native' cargo build --example web_socket_server_echo_raw_glommio --features glommio,simdutf8,web-socket-handshake --release
RUSTFLAGS='-C target-cpu=native' cargo run --example web_socket_server_echo_raw_glommio --features glommio,simdutf8,web-socket-handshake --release 127.0.0.1:8086 &

RUSTFLAGS='-C target-cpu=native' cargo build --example web_socket_server_echo_raw_tokio --features simdutf8,tokio,web-socket-handshake --release
RUSTFLAGS='-C target-cpu=native' cargo run --example web_socket_server_echo_raw_tokio --features simdutf8,tokio,web-socket-handshake --release 127.0.0.1:8087 &

sleep 1

RUSTFLAGS='-C target-cpu=native' cargo run --bin wtx-bench --release -- \
http://127.0.0.1:8080/fastwebsockets \
http://127.0.0.1:8081/gorilla-websocket \
http://127.0.0.1:8082/tokio-tungstenite \
http://127.0.0.1:8083/uWebSockets \
http://127.0.0.1:8084/wtx-hyper \
http://127.0.0.1:8085/wtx-raw-async-std \
http://127.0.0.1:8086/wtx-raw-glommio \
http://127.0.0.1:8087/wtx-raw-tokio
30 changes: 30 additions & 0 deletions .scripts/wtx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -euxo pipefail

cargo install rust-tools --git https://github.com/c410-f3r/regular-crates

rt='rust-tools --template you-rust'

CARGO_TARGET_DIR="$($rt target-dir)"
RUST_BACKTRACE=1
RUSTFLAGS="$($rt rust-flags)"

$rt rustfmt
$rt clippy

$rt test-generic wtx
$rt test-with-features wtx async-std
$rt test-with-features wtx async-trait
$rt test-with-features wtx base64
$rt test-with-features wtx futures-lite
$rt test-with-features wtx glommio
$rt test-with-features wtx http
$rt test-with-features wtx httparse
$rt test-with-features wtx hyper
$rt test-with-features wtx sha1
$rt test-with-features wtx simdutf8
$rt test-with-features wtx std
$rt test-with-features wtx tokio
$rt test-with-features wtx web-socket-handshake
$rt test-with-features wtx web-socket-hyper
19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[profile.profiling]
inherits = "release"
debug = true

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = false
panic = 'abort'
rpath = false
strip = "debuginfo"

[workspace]
members = ["wtx-bench", "wtx", "wtx-fuzz"]
resolver = "2"
4 changes: 4 additions & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2023-08-01"
components = ["clippy", "rustfmt"]
profile = "minimal"
13 changes: 13 additions & 0 deletions wtx-bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[dependencies]
hyper = { default-features = false, features = ["client", "http1", "server", "tcp"], version = "0.14" }
plotters = { default-features = false, features = ["histogram", "svg_backend"], version = "0.3" }
tokio = { default-features = false, features = ["macros", "rt-multi-thread"], version = "1.0" }
wtx = { features = ["tokio", "web-socket-handshake"], path = "../wtx" }

[package]
description = "Benchmarks"
edition = "2021"
license = "Apache-2.0"
name = "wtx-bench"
publish = false
version = "0.0.1"
7 changes: 7 additions & 0 deletions wtx-bench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Benchmarks

Call the `wtx-bench` binary passing the URLs of all different available echo servers.

```
cargo run --bin wtx-bench --release -- http://127.0.0.1:8080/some_server_name http://127.0.0.1:8081/another_server_name ..
```
Loading

0 comments on commit 94a98c1

Please sign in to comment.