Skip to content

Commit

Permalink
squash a lot of debuging to a single commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eranreshef-starkware committed May 5, 2024
1 parent 1e5b365 commit 7f1c104
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Benchmarks

on:
workflow_dispatch:
push:
branches: [main, eran/ci/benchmark-tests]

jobs:
storage-benchmark:
runs-on: ubuntu-latest
permissions:
contents: "write"
id-token: "write"

steps:
- name: Checkout repository
uses: actions/checkout@v3

# - name: Set a unique run identifier
# run: echo "UNIQE_ID=${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV

- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GOOGLE_CI_SA_CREDENTIALS }}"

- id: "get-credentials"
name: Get GKE credentials
uses: "google-github-actions/get-gke-credentials@v1"
with:
cluster_name: "${{ secrets.GKE_CI_CLUSTER_NAME }}"
location: "${{ secrets.GKE_CI_CLUSTER_REGION }}"

- name: Run load test
run: sh -c "deployments/storage-benchmark/run_benchmark.bash 5m"

- name: Download previous benchmark data
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark

# Run `github-action-benchmark` action
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: "Papyrus storage benchmark"
# What benchmark tool the output.txt came from
tool: 'customSmallerIsBetter'
# Where the output from the benchmark tool is stored
output-file-path: output.txt

# Push to gh-pages branch
- name: Push benchmark result
run: |
git switch gh-pages
git push https://github.com/starkware-libs/papyrus.git gh-pages:gh-pages --no-verify
git checkout -
20 changes: 20 additions & 0 deletions deployments/storage-benchmark/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
data:
queries.txt: |
{"get_nonce_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a69999"]}
{"get_nonce_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a69999"]}
{"get_nonce_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a69999"]}
{"get_nonce_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a69999"]}
{"get_nonce_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6"]}
{"get_storage_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6","0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c7"]}
{"get_class_hash_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6"]}
{"get_storage_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6","0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c7"]}
{"get_class_hash_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6"]}
{"get_storage_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6","0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a62647"]}
{"get_class_hash_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6"]}
{"get_class_hash_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6"]}
{"get_class_hash_at":[121,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6"]}
{"get_class_hash_at":[201,"0x20cfa74ee3564b4cd5435cdace0f9c4d43b939620e4a0bb5076105df0a626c6"]}
kind: ConfigMap
metadata:
name: queries
57 changes: 57 additions & 0 deletions deployments/storage-benchmark/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: storage-benchmark
name: storage-benchmark
spec:
replicas: 1
selector:
matchLabels:
app: storage-benchmark
template:
metadata:
labels:
app: storage-benchmark
spec:
securityContext:
fsGroup: 1000
initContainers:
- image: us.gcr.io/starkware-dev/papyrus-utils:latest
imagePullPolicy: Always
command:
- "storage_benchmark"
- "--queries_file_path"
- "/app/queries/queries.txt"
- "--db_path"
- "/app/data/"
- "--output_file_path"
- "/tmp/results/output.txt"
- "--chain_id"
- "SN_MAIN"
name: storage-benchmark
volumeMounts:
- mountPath: /app/data
name: data
- mountPath: /app/queries
name: queries
- mountPath: /tmp/results
name: results
containers:
- image: ubuntu
command:
- "sleep"
- "3600"
name: results-export
volumeMounts:
- mountPath: /tmp/results
name: results
volumes:
- name: data
persistentVolumeClaim:
claimName: data
- name: queries
configMap:
name: queries
- name: results
emptyDir: {}
15 changes: 15 additions & 0 deletions deployments/storage-benchmark/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
spec:
storageClassName: premium-rwo
dataSource:
name: papyrus-db-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
32 changes: 32 additions & 0 deletions deployments/storage-benchmark/run_benchmark.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euxo pipefail

BASE_PATH="deployments/storage-benchmark"
PVC_FILE="$BASE_PATH/pvc.yaml"
DEPLOYMENT_FILE="$BASE_PATH/deployment.yaml"
CM_FILE="$BASE_PATH/cm.yaml"

NS="papyrus-storage-benchmark"
DURRATION_TIMEOUT=$1

# create a PVC with the benchmarked storage
kubectl --namespace "$NS" apply -f "$PVC_FILE" --wait=true

# create a configmap with the actions to run
kubectl --namespace "$NS" apply -f "$CM_FILE"

# create the storage-benchmark deployment
kubectl --namespace "$NS" apply -f "$DEPLOYMENT_FILE" --wait=true

# get the created pod name
POD=$(kubectl get pods -l app=storage-benchmark --namespace "$NS" --no-headers -o custom-columns=":metadata.name")

# wait for pod to start (since the benchmark is done in an initContainer, when the pod is Ready it
# means the benchmark is done).
kubectl wait --namespace "$NS" --for=condition=ready pod "$POD" --timeout "$DURRATION_TIMEOUT"

# get the results file
kubectl --namespace "$NS" cp --container results-export "$POD":/tmp/results/output.txt output.txt

# delete all temp resources from the cluster
kubectl --namespace "$NS" delete -f "$BASE_PATH/*.yaml" --wait=true

0 comments on commit 7f1c104

Please sign in to comment.