Skip to content

Commit f452294

Browse files
authored
CCDB benchmark (#23)
* CCDB benchmark classes and script * Use truncate to delete ccdb data * Improve CCDB backend for speed * Add shield for the alibuild dashboard grafana * Use new CCDB api to get all the objects names of a task
1 parent 2569309 commit f452294

11 files changed

Lines changed: 788 additions & 197 deletions

File tree

Framework/CMakeLists.txt

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@ project(QualityControl)
1111
include(O2Utils)
1212
include(QualityControlDependencies)
1313

14-
# TODO make it required, once in its own repo
15-
if(ROOT_FOUND)
16-
message(STATUS "ROOT ${ROOT_VERSION} found in '${ROOTSYS}'")
17-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ROOTSYS}/share/root/cmake/modules)
18-
include(RootNewMacros)
19-
else()
20-
message(WARNING "ROOT not found, we won't compile the QC (skip, no error)")
21-
return()
22-
endif()
14+
message(STATUS "ROOT ${ROOT_VERSION} found in '${ROOTSYS}'")
15+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ROOTSYS}/share/root/cmake/modules)
16+
include(RootNewMacros)
2317

2418
# Set the default build type to "RelWithDebInfo"
2519
if(NOT CMAKE_BUILD_TYPE)
@@ -78,6 +72,7 @@ set(SRCS
7872
src/TaskDataProcessor.cxx
7973
src/TaskDataProcessorFactory.cxx
8074
src/TaskInterfaceDPL.cxx
75+
src/CcdbBenchmark.cxx
8176
)
8277

8378
set(HEADERS # needed for the dictionary generation
@@ -170,45 +165,48 @@ O2_GENERATE_EXECUTABLE(
170165
BUCKET_NAME ${BUCKET_NAME}
171166
)
172167

173-
if (FAIRROOT_FOUND)
174-
O2_GENERATE_EXECUTABLE(
175-
EXE_NAME alfaTestReceiver
176-
SOURCES src/alfaTestReceiver.cxx
177-
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
178-
BUCKET_NAME ${BUCKET_NAME}
179-
)
180-
181-
O2_GENERATE_EXECUTABLE(
182-
EXE_NAME qcConsumer
183-
SOURCES src/Consumer.cxx
184-
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
185-
BUCKET_NAME ${BUCKET_NAME}
186-
)
187-
endif()
168+
O2_GENERATE_EXECUTABLE(
169+
EXE_NAME alfaTestReceiver
170+
SOURCES src/alfaTestReceiver.cxx
171+
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
172+
BUCKET_NAME ${BUCKET_NAME}
173+
)
188174

189-
if(ROOT_FOUND) # TODO remove this once we have our own repo
190-
set(TEST_SRCS
191-
test/testDbFactory.cxx
192-
test/testMonitorObject.cxx
193-
test/testPublisher.cxx
194-
test/testQcInfoLogger.cxx
195-
test/testQCTask.cxx
196-
test/testQuality.cxx
197-
)
198-
199-
O2_GENERATE_TESTS(
200-
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
201-
BUCKET_NAME ${BUCKET_NAME}
202-
TEST_SRCS ${TEST_SRCS}
203-
)
204-
205-
O2_GENERATE_EXECUTABLE(
206-
EXE_NAME "tobject2json"
207-
SOURCES ${SRCS_TOBJECT2JSON}
175+
O2_GENERATE_EXECUTABLE(
176+
EXE_NAME qcConsumer
177+
SOURCES src/Consumer.cxx
208178
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
209-
BUCKET_NAME "o2_qc_tobject2json"
210-
)
211-
endif()
179+
BUCKET_NAME ${BUCKET_NAME}
180+
)
181+
182+
O2_GENERATE_EXECUTABLE(
183+
EXE_NAME ccdbBenchmark
184+
SOURCES src/runCcdbBenchmark.cxx
185+
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
186+
BUCKET_NAME ${BUCKET_NAME}
187+
)
188+
189+
set(TEST_SRCS
190+
test/testDbFactory.cxx
191+
test/testMonitorObject.cxx
192+
test/testPublisher.cxx
193+
test/testQcInfoLogger.cxx
194+
test/testQCTask.cxx
195+
test/testQuality.cxx
196+
)
197+
198+
O2_GENERATE_TESTS(
199+
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
200+
BUCKET_NAME ${BUCKET_NAME}
201+
TEST_SRCS ${TEST_SRCS}
202+
)
203+
204+
O2_GENERATE_EXECUTABLE(
205+
EXE_NAME "tobject2json"
206+
SOURCES ${SRCS_TOBJECT2JSON}
207+
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
208+
BUCKET_NAME "o2_qc_tobject2json"
209+
)
212210

213211
# Install extra scripts
214212
install(PROGRAMS script/qcDatabaseSetup.sh DESTINATION bin)

Framework/example-default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"password": "qc_user",
1010
"name": "quality_control",
1111
"implementation": "CCDB",
12-
"host": "localhost:8080"
12+
"host": "ccdb-test.cern.ch:8080"
1313
},
1414
"Activity": {
1515
"number": "42",

Framework/include/QualityControl/CcdbDatabase.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <ctime>
2020
#include <chrono>
2121
#include "QualityControl/DatabaseInterface.h"
22+
#include <curl/curl.h>
2223

2324
namespace o2 {
2425
namespace quality_control {
@@ -60,14 +61,37 @@ class CcdbDatabase : public DatabaseInterface
6061
void prepareTaskDataContainer(std::string taskName) override;
6162
std::vector<std::string> getListOfTasksWithPublications() override;
6263
std::vector<std::string> getPublishedObjectNames(std::string taskName) override;
64+
/**
65+
* Delete all the versions of the specified object.
66+
* @param taskName
67+
* @param objectName
68+
*/
69+
void truncateObject(std::string taskName, std::string objectName);
70+
/**
71+
* Delete the matching version of this object.
72+
* @todo Raise an exception if no such object exist.
73+
* @param taskName
74+
* @param objectName
75+
* @param timestamp
76+
*/
77+
void deleteObjectVersion(std::string taskName, std::string objectName, std::string timestamp);
6378

6479
private:
6580
long getCurrentTimestamp();
6681
std::string getTimestampString(long timestamp);
6782
long getFutureTimestamp(int secondsInFuture);
68-
std::string getListing(std::string subpath = "");
83+
/**
84+
* Return the listing of folder and/or objects in the subpath.
85+
* @param subpath The folder we want to list the children of.
86+
* @param accept The format of the returned string as an \"Accept\", i.e. text/plain, application/json, text/xml
87+
* @return The listing of folder and/or objects in the format requested and as returned by the http server.
88+
*/
89+
std::string getListing(std::string subpath = "", std::string accept = "text/plain");
6990

70-
std::string url;
91+
std::string mUrl;
92+
CURL *mCurl;
93+
CURLM *mMultiHandle;
94+
void curlInit();
7195
};
7296

7397
}

Framework/script/ccdb_benchmark.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/usr/bin/env bash
2+
set -e ;# exit on error
3+
set -u ;# exit when using undeclared variable
4+
#set -x ;# debugging
5+
6+
### Notes
7+
# FOR THE TIME BEING IT RUNS EVERYTHING LOCALLY
8+
# One must have ssh keys to connect to all hosts.
9+
10+
### Define matrix of tests
11+
NB_OF_TASKS=(1 10) ;#1 2 5 10 25 50 100);
12+
NB_OF_OBJECTS=(10 100);# 10 100 1000);
13+
SIZE_OBJECTS=(1);# 10 100 1000);# in kB
14+
15+
### Misc variables
16+
# The log prefix will be followed by the benchmark description, e.g. 1 task 1 checker... or an id or both
17+
LOG_FILE_PREFIX=/tmp/logCcdbBenchmark_
18+
NUMBER_CYCLES=60 ;# 180 ;# 1 sec per cycle -> ~ 3 minutes
19+
NODES=(
20+
#"aldaqci@aidrefflp01"
21+
"ccdb@barth-ccdb-606a6b90-1d83-48d5-8e46-ca72a63fc586"
22+
"ccdb@barth-ccdb-6f859d93-034c-4151-a4c8-571be0fe90f5"
23+
"ccdb@barth-ccdb-c518e99c-c05c-4066-a5dd-63613755985f"
24+
"ccdb@barth-ccdb-1394cef1-a627-4cf0-944f-40bf63f62ce1"
25+
"ccdb@barth-ccdb-a53241f0-f9f5-4862-8bca-66c081f7bd14"
26+
) ;# space delimited
27+
28+
29+
### Utility functions
30+
# Start a task in the background
31+
# \param 1 : host
32+
# \param 2 : name of the task
33+
# \param 3 : log file suffix
34+
# \param 4 : size of the objects
35+
# \param 5 : number of objects
36+
# \param 6 : number of tasks
37+
function startTask {
38+
host=$1
39+
name=$2
40+
log_file_suffix=$3
41+
size_objects=$4
42+
number_objects=$5
43+
number_tasks=$6
44+
log_file_name=${LOG_FILE_PREFIX}${log_file_suffix}.log
45+
echo "Starting task ${name} on host ${host}, logs in ${log_file_name}"
46+
cmd="cd alice ; alienv setenv --no-refresh QualityControl/latest -c ccdbBenchmark --max-iterations ${NUMBER_CYCLES} \
47+
--id ${name} --mq-config ~/alice/QualityControl/Framework/alfa.json --number-tasks ${number_tasks}\
48+
--delete 0 --control static --size-objects ${size_objects} --number-objects ${number_objects} \
49+
--monitoring-url influxdb-udp://aido2mon-gpn.cern.ch:8087 --task-name ${name} > ${log_file_name} 2>&1 "
50+
echo "ssh ${host} \"${cmd}\" &"
51+
ssh ${host} "${cmd}" &
52+
pidLastTask=$!
53+
}
54+
55+
# Kill all processes named "name"
56+
# \param 1 : name
57+
# \param 2 : host
58+
# \param 3 : extra flag for killall
59+
function killAll {
60+
name=$1
61+
host=$2
62+
extra=${3:-""}
63+
echo "Killing all processes called $name on $host"
64+
ssh ${host} "killall ${extra} ${name}> /dev/null 2>&1 || true" ;# ignore errors
65+
}
66+
67+
# Delete the database content
68+
# \param 1 : number of tasks
69+
function cleanDatabase {
70+
number_tasks=$1
71+
for (( task=0; task<$nb_tasks; task++ )); do
72+
name=benchmarkTask_${task}
73+
cmd="ccdbBenchmark --id test --mq-config ~/dev/alice/QualityControl/Framework/alfa.json --delete 1 --control static \
74+
--task-name ${name}" ;# > /dev/null 2>&1"
75+
echo ${cmd}
76+
eval ${cmd}
77+
done
78+
}
79+
80+
81+
### Benchmark starts here
82+
# Loop through the matrix of tests
83+
for nb_tasks in ${NB_OF_TASKS[@]}; do
84+
for nb_objects in ${NB_OF_OBJECTS[@]}; do
85+
for size_objects in ${SIZE_OBJECTS[@]}; do
86+
echo "*************************** $(date)
87+
Launching test for $nb_tasks tasks, $nb_objects objects, $size_objects kB objects"
88+
89+
echo "Kill all old processes"
90+
for machine in ${NODES[@]}; do
91+
killAll "ccdbBenchmark" ${machine} "-9"
92+
done
93+
94+
# echo "Delete database content"
95+
# cleanDatabase $nb_tasks
96+
97+
echo "Now start the tasks"
98+
for (( task=0; task<$nb_tasks; task++ )); do
99+
echo "*** ~~~ *** Start task"
100+
101+
# select a node for this task : task % #node -> index of node
102+
node_index=$((task%${#NODES[@]}))
103+
104+
startTask "${NODES[$node_index]}" benchmarkTask_${task} \
105+
"benchmarkTask_${task}_${nb_tasks}_${nb_objects}_${size_objects}" \
106+
${size_objects} ${nb_objects} ${nb_tasks}
107+
TASKS_PIDS+=($pidLastTask)
108+
done
109+
110+
echo "Now wait for the tasks to finish "
111+
wait ${TASKS_PIDS[*]};# the checker never stops, we can't just wait
112+
113+
sleep 5 # leave time to finish
114+
115+
for machine in ${NODES[@]}; do
116+
killAll "ccdbBenchmark" ${machine} "-9"
117+
done
118+
119+
sleep 5 # leave time to finish
120+
121+
TASKS_PIDS=()
122+
123+
echo "OK, ready for the next round !"
124+
125+
done
126+
done
127+
done
128+

0 commit comments

Comments
 (0)