Skip to content

Commit c725a7f

Browse files
committed
Run LDBC benchmarks during CI.
1 parent 919d9ae commit c725a7f

4 files changed

Lines changed: 64 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ benches/galen_data/
2929
benches/ldbc-graphalytics-data/
3030
nexmark_results.csv
3131
nexmark_comment.txt
32-
galen_results.csv
32+
galen_results.csv
33+
ldbc_results.csv

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ harness = false
102102

103103
[[bench]]
104104
name = "ldbc-graphalytics"
105+
required-features = ["with-csv"]
105106
harness = false
106107

107108
[[bench]]

benches/ldbc-graphalytics/main.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ use std::{
3030
borrow::Cow,
3131
cell::RefCell,
3232
fmt::Write as _,
33+
fs::OpenOptions,
3334
io::{self, Write},
3435
mem::{replace, size_of, take},
3536
num::{NonZeroU8, NonZeroUsize},
3637
ops::{Add, Neg},
38+
path::Path,
3739
rc::Rc,
3840
sync::{Arc, Mutex},
3941
thread,
@@ -43,6 +45,9 @@ use std::{
4345
#[global_allocator]
4446
static ALLOC: MiMalloc = MiMalloc;
4547

48+
// If you change this, also adjust `scripts/ci.bash`:
49+
const LDBC_RESULT_CSV: &str = "ldbc_results.csv";
50+
4651
enum OutputData {
4752
None,
4853
Bfs(DistanceSet<i8>),
@@ -238,6 +243,30 @@ fn main() {
238243
let kevps = evps / 1000.0;
239244
println!("achieved {kevps:.02} kEVPS ({evps:.02} EVPS)");
240245

246+
if config.output_csv {
247+
let results_file_already_exists = Path::new(LDBC_RESULT_CSV).is_file();
248+
// If the file exists, we append another row, this is different
249+
// from other benchmarks that can run everything with a single
250+
// invocation:
251+
let file = OpenOptions::new()
252+
.write(true)
253+
.append(results_file_already_exists)
254+
.create(!results_file_already_exists)
255+
.open(LDBC_RESULT_CSV)
256+
.expect("failed to open results csv file for writing");
257+
let mut csv_writer = csv::Writer::from_writer(file);
258+
259+
if !results_file_already_exists {
260+
// Write a header row if the file is newly created
261+
csv_writer
262+
.write_record(&["name", "algorithm", "dataset", "threads", "elapsed", "elements", "evps"])
263+
.expect("failed to write csv header");
264+
}
265+
csv_writer
266+
.write_record(&["ldbc", args.algorithm(), config.dataset.name, threads.get().to_string().as_str(), elapsed.as_secs_f64().to_string().as_str(), elements.to_string().as_str(), evps.to_string().as_str()])
267+
.expect("failed to write csv record");
268+
}
269+
241270
let output = replace(&mut *output.borrow_mut(), OutputData::None);
242271
match output {
243272
OutputData::None => println!("no output was produced"),
@@ -428,6 +457,14 @@ impl Args {
428457
| Self::ListDatasets { config } => config,
429458
}
430459
}
460+
461+
fn algorithm(&self) -> &str {
462+
match Self::parse() {
463+
Self::Bfs { .. } => "bfs",
464+
Self::Pagerank { .. } => "pagerank",
465+
_ => unreachable!(),
466+
}
467+
}
431468
}
432469

433470
#[derive(Debug, Clone, Copy, Parser)]
@@ -449,6 +486,10 @@ struct Config {
449486
#[clap(long, default_value = "5")]
450487
iters: NonZeroU8,
451488

489+
/// Store results in a csv file in addition to printing on the command-line.
490+
#[clap(long = "csv", env = "DBSP_RESULTS_AS_CSV")]
491+
output_csv: bool,
492+
452493
// When running with `cargo bench` the binary gets the `--bench` flag, so we
453494
// have to parse and ignore it so clap doesn't get angry
454495
#[doc(hidden)]

scripts/ci.bash

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ rm -rf gh-pages
1616
fi
1717
NEXMARK_CSV_FILE='nexmark_results.csv'
1818
GALEN_CSV_FILE='galen_results.csv'
19-
rm -f ${NEXMARK_CSV_FILE} ${GALEN_CSV_FILE}
19+
LDBC_CSV_FILE='ldbc_results.csv'
20+
rm -f ${NEXMARK_CSV_FILE} ${GALEN_CSV_FILE} ${LDBC_CSV_FILE}
2021
rm -f nexmark_comment.txt
2122

2223
# Run nexmark benchmark
@@ -31,6 +32,12 @@ cargo bench --bench nexmark --features with-nexmark -- --first-event-rate=${EVEN
3132
# Run galen benchmark
3233
cargo bench --bench galen --features="with-csv" -- --workers 10 --csv
3334

35+
# Run ldbc benchmarks
36+
cargo bench --bench ldbc-graphalytics -- bfs graph500-22 --threads 1
37+
cargo bench --bench ldbc-graphalytics -- bfs datagen-9_1-fb --threads 6
38+
cargo bench --bench ldbc-graphalytics -- pagerank graph500-22 --threads 1
39+
cargo bench --bench ldbc-graphalytics -- pagerank datagen-9_1-fb --threads 6
40+
3441
# Clone repo
3542
if [ ! -d "gh-pages" ]; then
3643
git clone --depth 1 -b main git@github.com:gz/dbsp-benchmarks.git gh-pages
@@ -68,6 +75,18 @@ mkdir -p ${DEPLOY_DIR}
6875
mv ${GALEN_CSV_FILE} ${DEPLOY_DIR}
6976
gzip -f ${DEPLOY_DIR}/${GALEN_CSV_FILE}
7077

78+
# Add ldbc results to repo
79+
DEPLOY_DIR="gh-pages/ldbc/${CI_MACHINE_TYPE}/${GITHUB_SHA}/"
80+
if [ -d "${DEPLOY_DIR}" ]; then
81+
# If we already have results for this SHA (the directory exists),
82+
# we will add the new results in a subdir
83+
DEPLOY_DIR=${DEPLOY_DIR}${DATE_PREFIX}
84+
fi
85+
# Copy ldbc results
86+
mkdir -p ${DEPLOY_DIR}
87+
mv ${LDBC_CSV_FILE} ${DEPLOY_DIR}
88+
gzip -f ${DEPLOY_DIR}/${LDBC_CSV_FILE}
89+
7190
# Update CI history plots
7291
python3 gh-pages/_scripts/ci_history.py --append --machine $CI_MACHINE_TYPE
7392

0 commit comments

Comments
 (0)