Skip to content
Draft
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
66 changes: 66 additions & 0 deletions .ci/run_test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ case $TestSuite in
"evmonetestsuite")
CMAKE_OPTIONS="$CMAKE_OPTIONS -DZEN_ENABLE_EVM=ON -DZEN_ENABLE_LIBEVM=ON"
;;
"benchmarksuite")
CMAKE_OPTIONS="$CMAKE_OPTIONS -DZEN_ENABLE_EVM=ON -DZEN_ENABLE_LIBEVM=ON -DZEN_ENABLE_SINGLEPASS_JIT=OFF -DZEN_ENABLE_MULTIPASS_JIT=ON"
;;
esac

case $CPU_EXCEPTION_TYPE in
Expand All @@ -94,6 +97,10 @@ if [[ $TestSuite == "evmonetestsuite" ]]; then
STACK_TYPES=("-DZEN_ENABLE_VIRTUAL_STACK=ON")
fi

if [[ $TestSuite == "benchmarksuite" ]]; then
STACK_TYPES=("-DZEN_ENABLE_VIRTUAL_STACK=ON")
fi

export PATH=$PATH:$PWD/build
CMAKE_OPTIONS_ORIGIN="$CMAKE_OPTIONS"

Expand Down Expand Up @@ -153,5 +160,64 @@ for STACK_TYPE in ${STACK_TYPES[@]}; do
./run_unittests.sh ../tests/evmone_unittests/EVMOneMultipassUnitTestsRunList.txt "./libdtvmapi.so,mode=multipass"
./run_unittests.sh ../tests/evmone_unittests/EVMOneInterpreterUnitTestsRunList.txt "./libdtvmapi.so,mode=interpreter"
;;
"benchmarksuite")
# Clone evmone and run performance regression check
EVMONE_DIR="evmone"
if [ ! -d "$EVMONE_DIR" ]; then
git clone --depth 1 --recurse-submodules -b for_test https://github.com/DTVMStack/evmone.git $EVMONE_DIR
fi

# Set default values for benchmark
BENCHMARK_THRESHOLD=${BENCHMARK_THRESHOLD:-0.10}
BENCHMARK_MODE=${BENCHMARK_MODE:-multipass}

# Copy DTVM library to evmone directory
cp build/lib/* $EVMONE_DIR/

cd $EVMONE_DIR

# Copy check_performance_regression.py from DTVM repo
cp ../tools/check_performance_regression.py ./

# Build evmone if not already built
if [ ! -f "build/bin/evmone-bench" ]; then
cmake -S . -B build -DEVMONE_TESTING=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel -j 16
fi

# Default summary output path (can be overridden via env)
BENCHMARK_SUMMARY_FILE=${BENCHMARK_SUMMARY_FILE:-/tmp/perf_summary.md}

# Run performance check based on mode
if [ -n "$BENCHMARK_SAVE_BASELINE" ]; then
echo "Saving performance baseline..."
python3 check_performance_regression.py \
--save-baseline "$BENCHMARK_SAVE_BASELINE" \
--output-summary "$BENCHMARK_SUMMARY_FILE" \
--lib ./libdtvmapi.so \
--mode "$BENCHMARK_MODE" \
--benchmark-dir test/evm-benchmarks/benchmarks
elif [ -n "$BENCHMARK_BASELINE_FILE" ]; then
echo "Checking performance regression against baseline..."
python3 check_performance_regression.py \
--baseline "$BENCHMARK_BASELINE_FILE" \
--threshold "$BENCHMARK_THRESHOLD" \
--output-summary "$BENCHMARK_SUMMARY_FILE" \
--lib ./libdtvmapi.so \
--mode "$BENCHMARK_MODE" \
--benchmark-dir test/evm-benchmarks/benchmarks
else
echo "Running benchmark suite without comparison..."
python3 check_performance_regression.py \
--save-baseline benchmark_results.json \
--output-summary "$BENCHMARK_SUMMARY_FILE" \
--lib ./libdtvmapi.so \
--mode "$BENCHMARK_MODE" \
--benchmark-dir test/evm-benchmarks/benchmarks
cat benchmark_results.json
fi

cd ..
;;
esac
done
113 changes: 113 additions & 0 deletions .github/workflows/dtvm_evm_test_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,116 @@ jobs:
export TestSuite=evmonetestsuite

bash .ci/run_test_suite.sh

performance_regression_check:
name: Performance Regression Check (10% threshold)
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
container:
image: dtvmdev1/dtvm-dev-x64:main
steps:
- name: Check out code
uses: actions/checkout@v3
with:
submodules: "true"
fetch-depth: 0

- name: Setup git safe directory
run: |
echo "Configuring git safe directory: ${{ github.workspace }}"
git config --global --add safe.directory /__w/DTVM/DTVM

- name: Code Format Check
run: |
./tools/format.sh check

- name: Build baseline (${{ github.base_ref }})
run: |
echo "Building baseline on branch: ${{ github.base_ref }}"

export LLVM_SYS_150_PREFIX=/opt/llvm15
export LLVM_DIR=$LLVM_SYS_150_PREFIX/lib/cmake/llvm
export PATH=$LLVM_SYS_150_PREFIX/bin:$PATH

# Save current state (including untracked files)
git stash push -u -m "perf-check-stash"
git checkout ${{ github.base_ref }}

# Build baseline
export CMAKE_BUILD_TARGET=Release
export ENABLE_ASAN=false
export RUN_MODE=multipass
export ENABLE_LAZY=false
export ENABLE_MULTITHREAD=true
export TestSuite=benchmarksuite
export CPU_EXCEPTION_TYPE='cpu'
export BENCHMARK_MODE=interpreter
export BENCHMARK_SAVE_BASELINE=/tmp/perf_baseline.json

bash .ci/run_test_suite.sh

- name: Build current PR and check regression
id: perf-check
run: |
echo "Building PR branch: ${{ github.sha }}"

export LLVM_SYS_150_PREFIX=/opt/llvm15
export LLVM_DIR=$LLVM_SYS_150_PREFIX/lib/cmake/llvm
export PATH=$LLVM_SYS_150_PREFIX/bin:$PATH

# Switch back to PR branch
git checkout ${{ github.sha }}
git stash pop || true

# Clean and rebuild for current PR
rm -rf build evmone

# Build and check
export CMAKE_BUILD_TARGET=Release
export ENABLE_ASAN=false
export RUN_MODE=multipass
export ENABLE_LAZY=false
export ENABLE_MULTITHREAD=true
export TestSuite=benchmarksuite
export CPU_EXCEPTION_TYPE='cpu'
export BENCHMARK_MODE=interpreter
export BENCHMARK_THRESHOLD=0.10
export BENCHMARK_BASELINE_FILE=/tmp/perf_baseline.json
export BENCHMARK_SUMMARY_FILE=/tmp/perf_summary.md

bash .ci/run_test_suite.sh
continue-on-error: true

- name: Comment on PR
if: always()
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const passed = '${{ steps.perf-check.outcome }}' === 'success';
let summary = '';
try {
summary = fs.readFileSync('/tmp/perf_summary.md', 'utf8');
} catch (e) {
summary = '_No benchmark summary available._';
}
const icon = passed ? '✅' : '⚠️';
const title = passed
? 'Performance Check Passed'
: 'Performance Regression Detected';
const body = `${icon} **${title}**\n\n${summary}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});

- name: Fail on regression
if: steps.perf-check.outcome == 'failure'
run: |
echo "::error::Performance regression detected. See logs for details."
exit 1
Loading
Loading