Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d1d3765
Add all target folders to gitignore
MauroToscano Feb 19, 2025
5e33d6b
Add RSP example
MauroToscano Feb 19, 2025
5844eea
Add rsp for pico and sp1
MauroToscano Feb 19, 2025
120927c
Add missing commands makefile
MauroToscano Feb 19, 2025
3e0c62a
Add target pico rsp
MauroToscano Feb 19, 2025
ec8fe5d
Add missing phony
MauroToscano Feb 19, 2025
932a5f4
Add missing phony
MauroToscano Feb 19, 2025
6623dd3
Add block
MauroToscano Feb 19, 2025
f7967c3
Fixes
MauroToscano Feb 19, 2025
ff26a67
Patch all crates in pico
MauroToscano Feb 19, 2025
34dff29
Fix rsp
MauroToscano Feb 19, 2025
e2004f5
Patch SP1 Reth
MauroToscano Feb 19, 2025
27ef8dd
Change RSP to the one that doesn't use C KZG
MauroToscano Feb 20, 2025
14e0442
Fix RSP
MauroToscano Feb 23, 2025
41b4e37
Merge
MauroToscano Feb 24, 2025
c3937a9
Gitignore
MauroToscano Feb 25, 2025
32560a0
Gitignore
MauroToscano Feb 25, 2025
fceed42
Gitignore
MauroToscano Feb 26, 2025
000eafc
Gitignore
MauroToscano Feb 26, 2025
874261a
Gitignore
MauroToscano Feb 26, 2025
cfbd7d1
New bench
MauroToscano Feb 26, 2025
b9e8b09
Add 36M block and benchmark_reth script
MauroToscano Feb 26, 2025
59444eb
Bench reth
MauroToscano Feb 26, 2025
b0c70ec
Fix build
MauroToscano Feb 26, 2025
b560067
Remove double target
MauroToscano Feb 26, 2025
5b44b71
Cuda bench plus benchmark
MauroToscano Feb 26, 2025
aaabda4
Fix cuda
MauroToscano Feb 26, 2025
88aa20f
Only sp1 for gpu
MauroToscano Feb 26, 2025
6104af1
Fix gpu
MauroToscano Feb 26, 2025
0e627f7
Change column of reth bench to megagas
MauroToscano Feb 26, 2025
7257f0b
Change column of reth bench to megagas
MauroToscano Feb 26, 2025
4be0ac7
Gi
MauroToscano Feb 26, 2025
2f04b13
--linear in readme
MauroToscano Feb 26, 2025
16e9cfb
Add test mode to benchmark
MauroToscano Feb 26, 2025
c007b5d
Remove diffs
MauroToscano Feb 27, 2025
c3eb2ee
update rsp version
JuArce Feb 28, 2025
04c1c25
pin rsp-client-executor version
JuArce Feb 28, 2025
c943c7a
update blocks
JuArce Feb 28, 2025
0f5c001
update pico rsp example
JuArce Mar 5, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
*.csv
!bench_results/*.csv
fibo_sp1/script/proof-with-pis.bin
Expand All @@ -8,3 +9,4 @@ fibo_sp1/script/proof-with-pis.bin
**/.vscode
venv
.idea
**/target
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.PHONY: fibo_sp1 fibo_pico fibo_risc0 build_pico build_sp1 build_risc0 build_pico_elf build_keccak_sp1 build_keccak_pico keccak_pico keccak_sp1 run_plotter create_python_venv install_requirements clean rsp_pico build_rsp_pico build_rsp_sp1 rsp_sp1
.PHONY: build_elf_fibo_pico build_fibo_pico build_fibo_sp1 build_fibo_risc0
.PHONY: build_elf_keccak_pico build_keccak_pico build_keccak_sp1 build_keccak_risc0
.PHONY: fibo_pico_wrapped fibo_sp1 fibo_risc0
Expand All @@ -20,6 +21,12 @@ build_elf_fibo_pico:
build_elf_keccak_pico:
cd keccak_pico/app && cargo pico build

build_pico_rsp_elf:
cd rsp_pico/app && cargo pico build

build_rsp_pico:
cd rsp_pico/prover && cargo build --release

build_fibo_pico:
cd fibo_pico/prover && cargo build --release

Expand All @@ -32,24 +39,33 @@ build_fibo_sp1:
build_keccak_sp1:
cd keccak_sp1/script && cargo build --release

build_rsp_sp1:
cd rsp_sp1/script && cargo build --release

build_fibo_risc0:
cd fibo_risc0/host && cargo build --release

rsp_pico:
./rsp_pico/target/release/prover block_data/$(BLOCK_MEGAGAS)M.bin

keccak_pico:
./keccak_pico/target/release/prover $(N)

build_keccak_risc0:
cd keccak_risc0/host && cargo build --release

fibo_pico_wrapped:
./fibo_pico/target/release/prover $(N)

keccak_pico:
./keccak_pico/target/release/prover $(N)

fibo_sp1:
./fibo_sp1/target/release/fibonacci $(N) $(PROOF_MODE)

keccak_sp1:
./keccak_sp1/target/release/prover $(N) $(PROOF_MODE)

rsp_sp1:
./rsp_sp1/script/target/release/prover block_data/$(BLOCK_MEGAGAS)M.bin

fibo_risc0:
RUST_LOG=info RISC0_INFO=1 ./fibo_risc0/target/release/host $(N)

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ If no INPUT_FILE is provided, it will use the default file `benchmark_keccak_res

The output will be `<path_to_file>.png`.

You can also use the flag ```--linear``` to generate plots in linear scale instead of log log

## Acknowledgments

To build this benches, we used provers made by Risc0, Succinct, and Pico. We also used examples of each as starting points for the programs
Binary file modified bench_results/18_feb_25_epyc7543_32c_128gb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions bench_results/26_feb_25_epyc7543_32c_128gb.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Prover,Megagas,Time
Prover Alpha,1,4m50.2s
Prover Beta,1,3m12.4s
Prover Alpha,6,23m47.8s
Prover Beta,6,16m15.9s
Prover Alpha,15,47m56.3s
Prover Beta,15,30m24.0s
Prover Alpha,24,100m17.1s
Binary file added bench_results/26_feb_25_epyc7543_32c_128gb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

./benchmark_fibo.sh
./benchmark_keccak.sh
./benchmark_reth.sh
67 changes: 67 additions & 0 deletions benchmark_reth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

format_time() {
local seconds=$1
if (( $(echo "$seconds >= 60" | bc -l) )); then
local minutes=$(echo "$seconds / 60" | bc)
local remaining_seconds=$(echo "$seconds - ($minutes * 60)" | bc)
if (( $(echo "$remaining_seconds == ${remaining_seconds%.*}" | bc -l) )); then
printf "%dm%ds" $minutes ${remaining_seconds%.*}
else
printf "%dm%.1fs" $minutes $remaining_seconds
fi
else
if (( $(echo "$seconds == ${seconds%.*}" | bc -l) )); then
printf "%ds" ${seconds%.*}
else
printf "%.1fs" $seconds
fi
fi
}

if [ -n "$TEST_MODE" ]; then
echo "Running in test mode"
N_VALUES=(1)
else
N_VALUES=(1 6 18 27 36)
fi

OUTPUT_FILE="benchmark_reth_results.csv"

# Detect CPU capabilities and set SP1 configuration
if grep -q "avx512" /proc/cpuinfo; then
SP1_RUSTFLAGS="-C target-cpu=native -C target-feature=+avx512f"
SP1_NAME="SP1-AVX512"
elif grep -q "avx2" /proc/cpuinfo; then
SP1_RUSTFLAGS="-C target-cpu=native"
SP1_NAME="SP1-AVX2"
else
SP1_RUSTFLAGS=""
SP1_NAME="SP1-Base"
fi

# Build all projects
echo "Building all projects..."
make build_rsp_sp1 RUSTFLAGS="$SP1_RUSTFLAGS"
make build_rsp_pico

# Initialize results file
echo "Prover,Megagas,Time" > $OUTPUT_FILE

for n in "${N_VALUES[@]}"; do
# Run rsp_pico benchmark
echo "Running RSP Pico with BLOCK_MEGAGAS=$n"
start=$(date +%s.%N)
make rsp_pico BLOCK_MEGAGAS=$n > /dev/null 2>&1
end=$(date +%s.%N)
time=$(echo "$end - $start" | bc)
echo "RSP Pico,$n,$(format_time $time)" >> $OUTPUT_FILE

# Run rsp_sp1 benchmark
echo "Running RSP SP1 with BLOCK_MEGAGAS=$n"
start=$(date +%s.%N)
make rsp_sp1 BLOCK_MEGAGAS=$n > /dev/null 2>&1
end=$(date +%s.%N)
time=$(echo "$end - $start" | bc)
echo "RSP SP1,$n,$(format_time $time)" >> $OUTPUT_FILE
done
46 changes: 46 additions & 0 deletions benchmark_reth_gpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

format_time() {
local seconds=$1
if (( $(echo "$seconds >= 60" | bc -l) )); then
local minutes=$(echo "$seconds / 60" | bc)
local remaining_seconds=$(echo "$seconds - ($minutes * 60)" | bc)
if (( $(echo "$remaining_seconds == ${remaining_seconds%.*}" | bc -l) )); then
printf "%dm%ds" $minutes ${remaining_seconds%.*}
else
printf "%dm%.1fs" $minutes $remaining_seconds
fi
else
if (( $(echo "$seconds == ${seconds%.*}" | bc -l) )); then
printf "%ds" ${seconds%.*}
else
printf "%.1fs" $seconds
fi
fi
}

if [ -n "$TEST_MODE" ]; then
echo "Running in test mode"
N_VALUES=(1)
else
N_VALUES=(1 6 18 27 36)
fi

OUTPUT_FILE="benchmark_reth_gpu_results.csv"

# Build all projects
echo "Building all projects..."
make build_rsp_sp1 SP1_PROVER="cuda"

# Initialize results file
echo "Prover,Megagas,Time" > $OUTPUT_FILE

for n in "${N_VALUES[@]}"; do
# Run rsp_sp1 benchmark
echo "Running RSP SP1 with BLOCK_MEGAGAS=$n"
start=$(date +%s.%N)
SP1_PROVER="cuda" make rsp_sp1 BLOCK_MEGAGAS=$n > /dev/null 2>&1
end=$(date +%s.%N)
time=$(echo "$end - $start" | bc)
echo "RSP SP1,$n,$(format_time $time)" >> $OUTPUT_FILE
done
Binary file added block_data/12M.bin
Binary file not shown.
Binary file added block_data/15M.bin
Binary file not shown.
Binary file added block_data/18M.bin
Binary file not shown.
Binary file added block_data/1M.bin
Binary file not shown.
Binary file added block_data/21M.bin
Binary file not shown.
Binary file added block_data/24M.bin
Binary file not shown.
Binary file added block_data/27M.bin
Binary file not shown.
Binary file added block_data/36M.bin
Binary file not shown.
Binary file added block_data/3M.bin
Binary file not shown.
Binary file added block_data/6M.bin
Binary file not shown.
Binary file added block_data/9M.bin
Binary file not shown.
46 changes: 30 additions & 16 deletions plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import os
import os

# Read arguments
if len(sys.argv) < 4:
print("Usage: python script.py input_csv xlabel function")
print("Example: python script.py data.csv 'Vector Size (bytes)' 'Keccak'")
print("Usage: python script.py input_csv xlabel function [--linear]")
print("Example: python script.py data.csv 'Vector Size (bytes)' 'Keccak' [--linear]")
sys.exit(1)

input_csv_path = sys.argv[1]
x_label = sys.argv[2]
function_type = sys.argv[3]
linear_scale = '--linear' in sys.argv # Check for --linear flag

# Read data from CSV
df = pd.read_csv(input_csv_path)
df['N'] = df['N'].astype(int)

# Dynamically find the column name ('N' or 'Megagas')
column_name = next((col for col in df.columns if col in ['N', 'Megagas']), None)
if column_name is None:
raise ValueError("Neither 'N' nor 'Megagas' column found in the DataFrame")

# Convert the column to integer
df[column_name] = df[column_name].astype(int)

def time_to_seconds(time_str):
time_str = time_str.strip()
Expand All @@ -39,15 +47,15 @@ def time_to_seconds(time_str):
print("Raw time conversion check:")
for idx, row in df.iterrows():
seconds = time_to_seconds(row['Time'])
print(f"{row['Prover']}, N={row['N']}, Time={row['Time']} => {seconds:.1f}s = {seconds/60:.2f}m")
print(f"{row['Prover']}, {column_name}={row[column_name]}, Time={row['Time']} => {seconds:.1f}s = {seconds/60:.2f}m")

df['Seconds'] = df['Time'].apply(time_to_seconds)
df['Minutes'] = df['Seconds'] / 60

# Print sorted data for validation
print("\nData sorted by Prover and N for validation:")
print(f"\nData sorted by Prover and {column_name} for validation:")
pd.set_option('display.float_format', '{:.2f}'.format)
validation_df = df.sort_values(['Prover', 'N'])[['Prover', 'N', 'Time', 'Minutes']]
validation_df = df.sort_values(['Prover', column_name])[['Prover', column_name, 'Time', 'Minutes']]
print(validation_df.to_string())

# Set style and color cycle
Expand All @@ -59,21 +67,27 @@ def time_to_seconds(time_str):
ax = plt.gca()

# Function to plot data
def plot_data(ax, data):
def plot_data(ax, data, use_linear=False):
for i, prover in enumerate(data['Prover'].unique()):
prover_data = data[data['Prover'] == prover].sort_values('N')
prover_data = data[data['Prover'] == prover].sort_values(column_name)
print(f"\nPlotting data for {prover}:")
print(prover_data[['N', 'Minutes']].to_string())
print(prover_data[[column_name, 'Minutes']].to_string())

ax.loglog(prover_data['N'], prover_data['Minutes'], 'o-',
label=prover, linewidth=2, markersize=8,
color=colors[i % len(colors)])
if use_linear:
ax.plot(prover_data[column_name], prover_data['Minutes'], 'o-',
label=prover, linewidth=2, markersize=8,
color=colors[i % len(colors)])
else:
ax.loglog(prover_data[column_name], prover_data['Minutes'], 'o-',
label=prover, linewidth=2, markersize=8,
color=colors[i % len(colors)])

# Plot log-log scale
plot_data(ax, df)
# Plot with chosen scale
plot_data(ax, df, use_linear=linear_scale)
ax.set_xlabel(x_label)
ax.set_ylabel('Time (minutes)')
ax.set_title(f'{function_type} Performance Comparison (Log-Log Scale)')
scale_label = 'Linear Scale' if linear_scale else 'Log-Log Scale'
ax.set_title(f'{function_type} Performance Comparison ({scale_label})')
ax.grid(True, alpha=0.3)
ax.legend(bbox_to_anchor=(1.02, 1), loc='upper left')

Expand Down
Binary file added proof-with-pis.bin
Binary file not shown.
1 change: 1 addition & 0 deletions rsp_pico/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading