Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 30 additions & 12 deletions .github/workflows/coprocessor-benchmark-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ on:
type: choice
options:
- "erc20"
- "dex"
- "synthetics"
- "all"
batch_size:
description: "Batch sizes (# FHE operations executed per batch)"
required: true
type: string
default: "5000"
scheduling_policy:
description: "Scheduling policy"
required: true
type: choice
options:
- "MAX_PARALLELISM"
- "MAX_LOCALITY"
- "LOOP"
- "FINE_GRAIN"

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -54,6 +64,7 @@ jobs:
timeout-minutes: 720 # 12 hours
permissions:
contents: 'read'
packages: 'read'
strategy:
fail-fast: false
# explicit include-based build matrix, of known valid options
Expand All @@ -64,11 +75,12 @@ jobs:
gcc: 11

steps:
- name: Install git LFS
- name: Wait for unattended upgrades to complete
run: |
sudo systemctl stop unattended-upgrades
sleep 10
sudo apt-get update

- name: Install git LFS
run: |
sudo apt-get install -y git-lfs
git lfs install

Expand All @@ -91,13 +103,16 @@ jobs:
} >> "${GITHUB_ENV}"

- name: Install rust
uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
with:
toolchain: nightly

- name: Install cargo dependencies
run: |
sudo systemctl stop docker
DEBIAN_FRONTEND=noninteractive sudo apt-get remove -y docker docker-engine docker.io containerd runc
DEBIAN_FRONTEND=noninteractive sudo apt-get purge -y docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-compose
sudo rm -rf /etc/bash_completion.d/docker /usr/local/bin/docker-compose /etc/bash_completion.d/docker-compose
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y protobuf-compiler cmake \
pkg-config libssl-dev \
libclang-dev docker-compose-v2 \
Expand All @@ -118,6 +133,13 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Init database
run: make init_db
working-directory: coprocessor/fhevm-engine/coprocessor
Expand All @@ -127,17 +149,13 @@ jobs:
with:
node-version: 20.x

- name: Build contracts
env:
HARDHAT_NETWORK: hardhat
- name: Start localstack
run: |
cp ./host-contracts/.env.example ./host-contracts/.env
npm --prefix ./host-contracts ci --include=optional
cd host-contracts && npm install && npm run deploy:emptyProxies && npx hardhat compile
docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:latest

- name: Run benchmarks on CPU
run: |
BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" make "benchmark_${{ inputs.benchmarks }}_cpu"
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor TXN_SENDER_TEST_GLOBAL_LOCALSTACK=1 BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" FHEVM_DF_SCHEDULE="${{ inputs.scheduling_policy }}" make -e "benchmark_${{ inputs.benchmarks }}_cpu"
working-directory: coprocessor/fhevm-engine/coprocessor

- name: Parse results
Expand All @@ -151,7 +169,7 @@ jobs:
--commit-date "${{ env.COMMIT_DATE }}" \
--bench-date "${{ env.BENCH_DATE }}" \
--walk-subdirs \
--name-suffix "operation_batch_size_${{ inputs.batch_size }}"
--name-suffix "operation_batch_size_${{ inputs.batch_size }}-schedule_${{ inputs.scheduling_policy }}"

- name: Upload parsed results artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
Expand Down
42 changes: 39 additions & 3 deletions .github/workflows/coprocessor-benchmark-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,40 @@ on:
type: choice
options:
- "erc20"
- "dex"
- "synthetics"
- "all"
batch_size:
description: "Batch sizes (# FHE operations executed per batch)"
required: true
type: string
default: "5000"
scheduling_policy:
description: "Scheduling policy"
required: true
type: choice
options:
- "MAX_PARALLELISM"
- "MAX_LOCALITY"
- "LOOP"
- "FINE_GRAIN"
optimization_target:
description: "Optimization target"
required: false
type: choice
options:
- "throughput"
- "latency"
default: "throughput"
benchmark_type:
description: "Benchmark type"
required: false
type: choice
options:
- "ALL"
- "THROUGHPUT"
- "LATENCY"
default: "ALL"

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -87,6 +114,7 @@ jobs:
timeout-minutes: 720 # 12 hours
permissions:
contents: 'read'
packages: 'read'
strategy:
fail-fast: false
# explicit include-based build matrix, of known valid options
Expand Down Expand Up @@ -125,7 +153,7 @@ jobs:
{
echo "BENCH_DATE=$(date --iso-8601=seconds)";
echo "COMMIT_DATE=$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})";
echo "COMMIT_HASH=$(git describe --tags --dirty)";
echo "COMMIT_HASH=$(git rev-parse HEAD)";
} >> "${GITHUB_ENV}"

- name: Install rust
Expand Down Expand Up @@ -155,6 +183,13 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Init database
run: make init_db
working-directory: coprocessor/fhevm-engine/coprocessor
Expand All @@ -174,7 +209,7 @@ jobs:

- name: Run benchmarks on GPU
run: |
BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" make "benchmark_${{ inputs.benchmarks }}_gpu"
BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" FHEVM_DF_SCHEDULE="${{ inputs.scheduling_policy }}" BENCHMARK_TYPE="${{ inputs.benchmark_type }}" OPTIMIZATION_TARGET="${{ inputs.optimization_target }}" make -e "benchmark_${{ inputs.benchmarks }}_gpu"
working-directory: coprocessor/fhevm-engine/coprocessor

- name: Parse results
Expand All @@ -188,7 +223,8 @@ jobs:
--commit-date "${{ env.COMMIT_DATE }}" \
--bench-date "${{ env.BENCH_DATE }}" \
--walk-subdirs \
--name-suffix "operation_batch_size_${{ inputs.batch_size }}"
--crate "coprocessor/fhevm-engine/coprocessor" \
--name-suffix "operation_batch_size_${{ inputs.batch_size }}-schedule_${{ inputs.scheduling_policy }}-optimization_target_${{ inputs.optimization_target }}"

- name: Upload parsed results artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
Expand Down
2 changes: 1 addition & 1 deletion ci/benchmark_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
parser.add_argument(
"--crate",
dest="crate",
default="fhevm-engine/coprocessor",
default="coprocessor/fhevm-engine/coprocessor",
help="Crate for which benchmarks have run",
)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

8 changes: 8 additions & 0 deletions coprocessor/fhevm-engine/coprocessor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ scheduler = { path = "../scheduler" }
[features]
nightly-avx512 = ["tfhe/nightly-avx512"]
gpu = ["tfhe/gpu", "scheduler/gpu", "fhevm-engine-common/gpu"]
bench = []
latency = ["fhevm-engine-common/latency"]
throughput = ["fhevm-engine-common/throughput"]

[dev-dependencies]
testcontainers = { workspace = true }
Expand Down Expand Up @@ -81,3 +84,8 @@ harness = false
name = "synthetics"
path = "benches/synthetics.rs"
harness = false

[[bench]]
name = "dex"
path = "benches/dex.rs"
harness = false
21 changes: 15 additions & 6 deletions coprocessor/fhevm-engine/coprocessor/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

DB_URL ?= DATABASE_URL=postgres://postgres:[email protected]:5432/coprocessor
OPTIMIZATION_TARGET ?= throughput

.PHONY: build
build:
Expand Down Expand Up @@ -41,25 +42,33 @@ clean_run:

.PHONY: benchmark_erc20_gpu # Run ECR20 transfer benchmarks on GPU
benchmark_erc20_gpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --features=gpu --
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --features=gpu,bench,$(OPTIMIZATION_TARGET) --

.PHONY: benchmark_dex_gpu # Run DEX benchmarks on GPU
benchmark_dex_gpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench dex --features=gpu,bench,$(OPTIMIZATION_TARGET) --

.PHONY: benchmark_synthetics_gpu # Run all benchmarks on GPU
benchmark_synthetics_gpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --features=gpu --
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --features=gpu,bench,$(OPTIMIZATION_TARGET) --

.PHONY: benchmark_all_gpu # Run all benchmarks on GPU
benchmark_all_gpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench synthetics --features=gpu --
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench dex --bench synthetics --features=gpu,bench,$(OPTIMIZATION_TARGET) --


.PHONY: benchmark_erc20_cpu # Run ECR20 transfer benchmarks on CPU
benchmark_erc20_cpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --features=bench --

.PHONY: benchmark_dex_cpu # Run DEX benchmarks on CPU
benchmark_dex_cpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench dex --features=bench --

.PHONY: benchmark_synthetics_cpu # Run all benchmarks on CPU
benchmark_synthetics_cpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --features=bench --

.PHONY: benchmark_all_cpu # Run all benchmarks on CPU
benchmark_all_cpu:
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench synthetics --
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench dex --bench synthetics --features=bench --
Loading
Loading