Skip to content

Commit 45048fd

Browse files
committed
[SPARK-52662] Add SparkApp benchmark
### What changes were proposed in this pull request? This PR aims to add a simple E2E benchmark for `SparkApp` as a baseline. ### Why are the changes needed? To check `SparkApp` creation and deletion in a measurable way. ### Does this PR introduce _any_ user-facing change? No, this is a test. ### How was this patch tested? Manual tests. When the argument is not given, the default value for the number of jobs is 1000. ``` $ sh tests/benchmark/sparkapps.sh 100 CLEAN UP NAMESPACE FOR BENCHMARK START BENCHMARK WITH 100 JOBS FINISHED 100 JOBS IN 56 SECONDS. DELETED 100 JOBS IN 40 SECONDS. ``` ``` $ sh tests/benchmark/sparkapps.sh CLEAN UP NAMESPACE FOR BENCHMARK START BENCHMARK WITH 1000 JOBS FINISHED 1000 JOBS IN 340 SECONDS. DELETED 1000 JOBS IN 401 SECONDS. ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#273 from dongjoon-hyun/SPARK-52662. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent b0255cf commit 45048fd

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/benchmark/sparkapps.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
# 1. Clear the existing CRDs before staring the benchmark
21+
echo "CLEAN UP NAMESPACE FOR BENCHMARK"
22+
kubectl get sparkapplications.spark.apache.org -o name | xargs kubectl delete
23+
24+
NUM="${1:-1000}"
25+
echo "START BENCHMARK WITH $NUM JOBS"
26+
27+
# 2. Creation Benchmark
28+
filename=$(mktemp)
29+
30+
for i in $(seq -f "%05g" 1 $NUM); do
31+
cat << EOF >> $filename
32+
apiVersion: spark.apache.org/v1beta1
33+
kind: SparkApplication
34+
metadata:
35+
name: test-${i}
36+
spec:
37+
mainClass: "org.apache.spark.examples.DriverSubmissionTest"
38+
jars: "local:///opt/spark/examples/jars/spark-examples.jar"
39+
driverArgs: ["0"]
40+
sparkConf:
41+
spark.kubernetes.driver.request.cores: "100m"
42+
spark.kubernetes.driver.request.memory: "100Mi"
43+
spark.kubernetes.driver.master: "local[1]"
44+
spark.kubernetes.authenticate.driver.serviceAccountName: "spark"
45+
spark.kubernetes.container.image: "apache/spark:4.0.0"
46+
runtimeVersions:
47+
sparkVersion: "4.0.0"
48+
---
49+
EOF
50+
done
51+
52+
start=`date +%s`
53+
kubectl apply -f $filename > /dev/null
54+
while [ $(kubectl get sparkapplications.spark.apache.org | grep ResourceReleased | wc -l) -lt $NUM ]
55+
do
56+
sleep 1
57+
done
58+
end=`date +%s`
59+
completionTime=$((end - start))
60+
echo "FINISHED $NUM JOBS IN $completionTime SECONDS."
61+
62+
# 3. Deletion Benchmark
63+
start=`date +%s`
64+
kubectl get sparkapplications.spark.apache.org -o name | xargs kubectl delete > /dev/null
65+
end=`date +%s`
66+
deletionTime=$((end - start))
67+
echo "DELETED $NUM JOBS IN $deletionTime SECONDS."

0 commit comments

Comments
 (0)