Skip to content

Commit

Permalink
first commit for storage-benchmark CI
Browse files Browse the repository at this point in the history
  • Loading branch information
eranreshef-starkware committed May 2, 2024
1 parent 0483361 commit cd5a74f
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Benchmarks

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

jobs:
deploy-benchmark-teardown:
runs-on: ubuntu-latest
permissions:
contents: "read"
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: Parse load test results
run: |
pwd
ls -al
# - name: Clean the deployment
# if: always()
# run: helm delete --namespace papyrus papyrus-${UNIQE_ID}
36 changes: 36 additions & 0 deletions deployments/storage-benchmark/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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"]}
results.json: |
[
{
"name": "My Custom Smaller Is Better Benchmark - CPU Load",
"unit": "Percent",
"value": 50
},
{
"name": "My Custom Smaller Is Better Benchmark - Memory Used",
"unit": "Megabytes",
"value": 100,
"range": "3",
"extra": "Value for Tooltip: 25\nOptional Num #2: 100\nAnything Else!"
}
]
kind: ConfigMap
metadata:
creationTimestamp: null
name: queries
60 changes: 60 additions & 0 deletions deployments/storage-benchmark/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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:
# - sh
# - -c
# - "sleep 3600 && cp /app/queries/results.json /tmp/results/output.txt"
- "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 cd5a74f

Please sign in to comment.