Skip to content

Commit

Permalink
draft: benchmark info logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Feb 9, 2024
1 parent 7122d3c commit 75768b9
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 104 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/bench_logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import subprocess
import logging
import time
import os

def bench_logs(color: bool, target: str, iterations: int, level: str):
logging.info("🎯 Initalize environnment")

start = time.time()

env = {}
env['BENCH_LOG_COLOR'] = str(color)
env['BENCH_LOG_TARGET'] = target
env['BENCH_LOG_ITERS'] = str(iterations)
env['BENCH_LOG_FILTER'] = level

for key, value in env.items():
print(f"{key}: {value}")

try:
bench_process = subprocess.Popen(
["./bench_logger"],
stdout=subprocess.DEVNULL,
env=env
)

stdout, stderr = bench_logger.communicate()

if stderr:
logging.error(stderr.decode())

except subprocess.CalledProcessError as e:
logging.error(f"🚨 Command failed with return code {e.returncode}")

elapsed_time = time.time() - start

logging.info("🪓 Destroy environment")

try:
subprocess.run(["kill", str(bench_process.pid)])
except subprocess.CalledProcessError as e:
logging.error(f"🚨 Failed to destroy environnement {e.returncode}")

logging.info(f"benching logs, with color: {color}, to {target}, level {level}, {iterations} iterations. Time: {elapsed_time}")

logging.basicConfig(encoding='utf-8', level=logging.INFO)
logging.info("💣 Launching benchmark")

bench_logs(True, "stdout", 1000000, "debug")
bench_logs(True, "stdout", 1000000, "trace")
bench_logs(True, "udp", 1000000, "debug")
bench_logs(True, "udp", 1000000, "trace")
230 changes: 126 additions & 104 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,61 @@ env:
CARGO_TERM_COLOR: always

jobs:
build-bombardier:
name: Build Bombardier 💣️
runs-on: ubuntu-latest
steps:
- name: Clone bombardier
uses: actions/checkout@v4
with:
repository: codesenberg/bombardier
path: .

- uses: actions/setup-go@v5
with:
go-version: '1.18'
check-latest: false

- name: Build bombardier
run: go build -o bombardier

- name: 📤 Upload bombardier
uses: actions/upload-artifact@v4
with:
name: bombardier
path: bombardier

build-lagging_server:
name: Build Lagging_Server ⚡️
runs-on: ubuntu-latest
steps:
- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""

- name: Clone lagging_server
uses: actions/checkout@v4
with:
repository: CleverCloud/lagging_server
path: .

- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
prefix-key: "lagging_server"
# build-bombardier:
# name: Build Bombardier 💣️
# runs-on: ubuntu-latest
# steps:
# - name: Clone bombardier
# uses: actions/checkout@v4
# with:
# repository: codesenberg/bombardier
# path: .

# - uses: actions/setup-go@v5
# with:
# go-version: '1.18'
# check-latest: false

# - name: Build bombardier
# run: go build -o bombardier

# - name: 📤 Upload bombardier
# uses: actions/upload-artifact@v4
# with:
# name: bombardier
# path: bombardier

# build-lagging_server:
# name: Build Lagging_Server ⚡️
# runs-on: ubuntu-latest
# steps:
# - name: Install rust toolchain
# uses: actions-rust-lang/setup-rust-toolchain@v1
# with:
# rustflags: ""

# - name: Clone lagging_server
# uses: actions/checkout@v4
# with:
# repository: CleverCloud/lagging_server
# path: .

# - uses: Swatinem/rust-cache@v2
# with:
# cache-all-crates: true
# prefix-key: "lagging_server"

- name: Build lagging_server
run: cargo build --release
# - name: Build lagging_server
# run: cargo build --release

- name: 📤 Upload lagging_server
uses: actions/upload-artifact@v4
with:
name: lagging_server
path: target/release/lagging_server
# - name: 📤 Upload lagging_server
# uses: actions/upload-artifact@v4
# with:
# name: lagging_server
# path: target/release/lagging_server

build-sozu:
name: Build Sozu 🦀
name: Build Sozu and bench_logger 🦀
runs-on: ubuntu-latest
steps:
- name: Install protobuf compiler
Expand All @@ -79,69 +79,85 @@ jobs:
cache-all-crates: true
prefix-key: "sozu"

- name: Build Sozu
run: cargo build --release
# - name: Build Sozu
# run: cargo build --release

- name: Build Sozu bench logger (for benchmarking)
run: cargo build --release --example bench_logger

- name: 📤 Upload sozu
# - name: 📤 Upload sozu
# uses: actions/upload-artifact@v4
# with:
# name: sozu
# path: target/release/sozu

- name: 📤 Upload sozu bench logger
uses: actions/upload-artifact@v4
with:
name: sozu
path: target/release/sozu

name: bench_logger
path: target/release/examples/bench_logger


bench:
name: Benchmark 🎯
runs-on: ubuntu-latest
needs: [build-bombardier, build-lagging_server, build-sozu]
# needs: [build-bombardier, build-lagging_server, build-sozu]
needs: [build-sozu]
steps:
- uses: actions/checkout@v4

- name: 📥 Download bombardier
uses: actions/download-artifact@v4
with:
name: bombardier
path: .github/workflows
- name: 📥 Download lagging_server
uses: actions/download-artifact@v4
with:
name: lagging_server
path: .github/workflows
- name: 📥 Download sozu
# - name: 📥 Download bombardier
# uses: actions/download-artifact@v4
# with:
# name: bombardier
# path: .github/workflows
# - name: 📥 Download lagging_server
# uses: actions/download-artifact@v4
# with:
# name: lagging_server
# path: .github/workflows
# - name: 📥 Download sozu
# uses: actions/download-artifact@v4
# with:
# name: sozu
# path: .github/workflows
- name: 📥 Download sozu bench logger
uses: actions/download-artifact@v4
with:
name: sozu
name: bench_logger
path: .github/workflows

- name: Host mapping sozu.io domains
run: |
sudo echo "0.0.0.0 sozu.io" | sudo tee -a /etc/hosts
sudo echo "0.0.0.0 rsa-2048.sozu.io" | sudo tee -a /etc/hosts
sudo echo "0.0.0.0 rsa-4096.sozu.io" | sudo tee -a /etc/hosts
sudo echo "0.0.0.0 ecdsa.sozu.io" | sudo tee -a /etc/hosts
- name: Generate TLS key rsa 2048
working-directory: .github/workflows
run: |
openssl req -newkey rsa:2048 -nodes -keyout rsa-2048.key -out rsa-2048.csr -config rsa-2048.cnf
openssl x509 -req -days 365 -in rsa-2048.csr -signkey rsa-2048.key -out rsa-2048.pem -extensions req_ext -extfile rsa-2048.cnf
sudo cp rsa-2048.pem /usr/local/share/ca-certificates/rsa-2048.crt
sudo update-ca-certificates
# - name: Host mapping sozu.io domains
# run: |
# sudo echo "0.0.0.0 sozu.io" | sudo tee -a /etc/hosts
# sudo echo "0.0.0.0 rsa-2048.sozu.io" | sudo tee -a /etc/hosts
# sudo echo "0.0.0.0 rsa-4096.sozu.io" | sudo tee -a /etc/hosts
# sudo echo "0.0.0.0 ecdsa.sozu.io" | sudo tee -a /etc/hosts

# - name: Generate TLS key rsa 2048
# working-directory: .github/workflows
# run: |
# openssl req -newkey rsa:2048 -nodes -keyout rsa-2048.key -out rsa-2048.csr -config rsa-2048.cnf
# openssl x509 -req -days 365 -in rsa-2048.csr -signkey rsa-2048.key -out rsa-2048.pem -extensions req_ext -extfile rsa-2048.cnf
# sudo cp rsa-2048.pem /usr/local/share/ca-certificates/rsa-2048.crt
# sudo update-ca-certificates

- name: Generate TLS key rsa 4096
working-directory: .github/workflows
run: |
openssl req -newkey rsa:4096 -nodes -keyout rsa-4096.key -out rsa-4096.csr -config rsa-4096.cnf
openssl x509 -req -days 365 -in rsa-4096.csr -signkey rsa-4096.key -out rsa-4096.pem -extensions req_ext -extfile rsa-4096.cnf
sudo cp rsa-4096.pem /usr/local/share/ca-certificates/rsa-4096.crt
sudo update-ca-certificates
# - name: Generate TLS key rsa 4096
# working-directory: .github/workflows
# run: |
# openssl req -newkey rsa:4096 -nodes -keyout rsa-4096.key -out rsa-4096.csr -config rsa-4096.cnf
# openssl x509 -req -days 365 -in rsa-4096.csr -signkey rsa-4096.key -out rsa-4096.pem -extensions req_ext -extfile rsa-4096.cnf
# sudo cp rsa-4096.pem /usr/local/share/ca-certificates/rsa-4096.crt
# sudo update-ca-certificates

- name: Generate TLS key ecdsa
working-directory: .github/workflows
run: |
openssl ecparam -name prime256v1 -genkey -out ecdsa.key
openssl req -new -key ecdsa.key -out ecdsa.csr -config ecdsa.cnf
openssl x509 -req -days 365 -in ecdsa.csr -signkey ecdsa.key -out ecdsa.pem -extensions req_ext -extfile ecdsa.cnf
sudo cp ecdsa.pem /usr/local/share/ca-certificates/ecdsa.crt
sudo update-ca-certificates
# - name: Generate TLS key ecdsa
# working-directory: .github/workflows
# run: |
# openssl ecparam -name prime256v1 -genkey -out ecdsa.key
# openssl req -new -key ecdsa.key -out ecdsa.csr -config ecdsa.cnf
# openssl x509 -req -days 365 -in ecdsa.csr -signkey ecdsa.key -out ecdsa.pem -extensions req_ext -extfile ecdsa.cnf
# sudo cp ecdsa.pem /usr/local/share/ca-certificates/ecdsa.crt
# sudo update-ca-certificates

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -150,12 +166,18 @@ jobs:

- name: Fix rights
working-directory: .github/workflows
# chmod +x bombardier
# chmod +x lagging_server
# chmod +x sozu
run: |
chmod +x bombardier
chmod +x lagging_server
chmod +x sozu
chmod +x bench_logger
- name: ⚡ Launch bench
# - name: ⚡ Launch bench
# working-directory: .github/workflows
# run:
# python bench.py

- name: Bench the logs
working-directory: .github/workflows
run:
python bench.py
python bench_logs.py

0 comments on commit 75768b9

Please sign in to comment.