Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmake/modules/RootBenchOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
# # TBD: to introduce special function for options (similar to root.git)
#----------------------------------------------------------------------------
option(coverage OFF)
option(rootbench-datafiles OFF)

option(rootbench-datafiles OFF "Download files from root.cern.ch")

option(experiment-datafiles OFF "Use for benchmarking CMS and ATLAS files (> 1.5 GB)")
if(experiment-datafiles)
# We need to enable download of datafiles from oot.cern.ch
set(rootbench-datafiles ON CACHE BOOL "Download files from root.cern.ch" FORCE)
endif()
36 changes: 18 additions & 18 deletions root/io/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ if(ROOT_root7_FOUND) # using ROOT_root7_FOUND as a proxy for "c++ standard >= 14
RB_ADD_GBENCHMARK(TFile_RDFSnapshot
TFile_RDFSnapshot.cxx
LABEL short
LIBRARIES Core RIO ROOTDataFrame Tree TreePlayer MathCore)
LIBRARIES Core RIO ROOTDataFrame Tree TreePlayer MathCore)
endif()

if(rootbench-datafiles)
if(rootbench-datafiles AND experiment-datafiles)

# FIXME:Compression tests needs to have libEvent.so which is a part of ROOT build
# Preloading doesn't help...
#if(TARGET Event)
Expand All @@ -21,22 +22,21 @@ if(rootbench-datafiles)
# DOWNLOAD_DATAFILES Event0-sample.root)
#endif()

# FIXME: too long benchmarks, needs to be optimised
#RB_ADD_GBENCHMARK(CompressionBenchmarks_LHCb
# TFile_LHCb_Benchmarks.cxx
# LABEL short
# LIBRARIES Core RIO
# DOWNLOAD_DATAFILES lhcb_B2ppKK2011_md_noPIDstrip.root)
RB_ADD_GBENCHMARK(CompressionBenchmarks_LHCb
TFile_LHCb_Benchmarks.cxx
LABEL short
LIBRARIES Core RIO Tree
DOWNLOAD_DATAFILES lhcb_B2ppKK2011_md_noPIDstrip.root)

#RB_ADD_GBENCHMARK(CompressionBenchmarks_NanoAOD
# TFile_NanoAOD_Benchmarks.cxx
# LABEL short
# LIBRARIES Core RIO
# DOWNLOAD_DATAFILES Run2012B_DoubleMuParked.root)
RB_ADD_GBENCHMARK(CompressionBenchmarks_NanoAOD
TFile_NanoAOD_Benchmarks.cxx
LABEL short
LIBRARIES Core RIO Tree
DOWNLOAD_DATAFILES Run2012B_DoubleMuParked.root NanoAOD_DoubleMuon_CMS2011OpenData.root)

#RB_ADD_GBENCHMARK(CompressionBenchmarks_ATLAS
# TFile_ATLAS_Benchmarks.cxx
# LABEL short
# LIBRARIES Core RIO
# DOWNLOAD_DATAFILES gg_data-zstd.root)
RB_ADD_GBENCHMARK(CompressionBenchmarks_ATLAS
TFile_ATLAS_Benchmarks.cxx
LABEL short
LIBRARIES Core RIO Tree
DOWNLOAD_DATAFILES gg_data-zstd.root)
endif()
81 changes: 54 additions & 27 deletions root/io/io/TFile_ATLAS_Benchmarks.cxx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#include "TFile.h"
#include "TTree.h"
#include "TStopwatch.h"

#include "benchmark/benchmark.h"
#include "rootbench/RBConfig.h"

#include <map>
#include <iostream>

static std::string GetAlgoName(int algo) {
std::map<int, std::string> algoName = {
{1, "zlib"},
{2, "lzma"},
{4, "lz4"},
{5, "zstd"}
{5, "zstd"},
{6, "flzma2"}
};

if (algoName.find(algo) != algoName.end())
Expand All @@ -21,47 +24,57 @@ static std::string GetAlgoName(int algo) {
}

static void BM_ATLAS_Compress(benchmark::State &state, int algo) {
TFile *oldfile = new TFile((RB::GetDataDir() + "/gg_data-zstd.root").c_str());
TTree *oldtree = (TTree*)oldfile->Get("mini");

std::string path = RB::GetDataDir() + "/gg_data-zstd.root";
auto oldfile = TFile::Open(path.c_str());
auto oldtree = oldfile->Get<TTree>("mini");
TStopwatch timer;
const auto nevents = oldtree->GetEntries();
int comp_level = state.range(0);
std::string filename = "level_" + std::to_string(comp_level) + "_atlas_" + GetAlgoName(algo) + ".root";

for (auto _ : state) {
state.PauseTiming();

TFile *newfile = new TFile(filename.c_str(), "recreate");
TTree *newtree = oldtree->CloneTree();
auto newfile = new TFile(filename.c_str(), "recreate");
newfile->SetCompressionAlgorithm(algo);
newfile->SetCompressionLevel(comp_level);
auto newtree = oldtree->CloneTree();

state.ResumeTiming();
timer.Start();
newfile->Write();
timer.Stop();
state.PauseTiming();

state.counters["comp_size"] = newfile->GetBytesWritten();
state.counters["comp_size"] = newfile->GetSize();
double rtime = timer.RealTime();
double ctime = timer.CpuTime();
state.counters["mb_rts"] = newfile->GetSize()/rtime;
state.counters["mb_cts"] = newfile->GetSize()/ctime;
newfile->Close();

state.ResumeTiming();
}
}

static void BM_ATLAS_Decompress(benchmark::State &state, int algo) {
int comp_level = state.range(0);

int nb;
TStopwatch timer;
std::string filename = "level_" + std::to_string(comp_level) + "_atlas_" + GetAlgoName(algo) + ".root";
for (auto _ : state) {
TFile *hfile = new TFile(filename.c_str());
TTree *tree = (TTree*)hfile->Get("mini");

Int_t nevent = (Int_t)tree->GetEntries();

Int_t nb = 0;
timer.Start();
TFile f(filename.c_str());
auto tree = static_cast<TTree *>(f.Get("mini"));
const auto nevents = tree->GetEntries();
Int_t ev;

for (ev = 0; ev < nevent; ev++) {
for (ev = 0; ev < nevents; ++ev) {
nb += tree->GetEntry(ev);
}
timer.Stop();
double rtime = timer.RealTime();
double ctime = timer.CpuTime();
state.counters["mb_rts"] = f.GetSize()/rtime;
state.counters["mb_cts"] = f.GetSize()/ctime;
f.Close();
}
}

Expand All @@ -77,6 +90,9 @@ static void BM_ATLAS_Compress_LZ4(benchmark::State &state) {
static void BM_ATLAS_Compress_ZSTD(benchmark::State &state) {
BM_ATLAS_Compress(state, 5);
}
static void BM_ATLAS_Compress_FLZMA2(benchmark::State &state) {
BM_ATLAS_Compress(state, 6);
}

static void BM_ATLAS_Decompress_ZLIB(benchmark::State &state) {
BM_ATLAS_Decompress(state, 1);
Expand All @@ -90,40 +106,51 @@ static void BM_ATLAS_Decompress_LZ4(benchmark::State &state) {
static void BM_ATLAS_Decompress_ZSTD(benchmark::State &state) {
BM_ATLAS_Decompress(state, 5);
}

static void BM_ATLAS_Decompress_FLZMA2(benchmark::State &state) {
BM_ATLAS_Decompress(state, 6);
}

BENCHMARK(BM_ATLAS_Compress_ZLIB)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Compress_LZMA)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Compress_LZ4)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Compress_ZSTD)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Compress_FLZMA2)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(1);



BENCHMARK(BM_ATLAS_Decompress_ZLIB)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Decompress_LZMA)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Decompress_LZ4)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Decompress_ZSTD)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);
->Unit(benchmark::kMillisecond)->Iterations(1);

BENCHMARK(BM_ATLAS_Decompress_FLZMA2)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(1);


BENCHMARK_MAIN();
19 changes: 17 additions & 2 deletions root/io/io/TFile_CompressionBenchmarks_MainEvent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ static std::string GetAlgoName(int algo) {
{1, "zlib"},
{2, "lzma"},
{4, "lz4"},
{5, "zstd"}
{5, "zstd"},
{6, "flzma2"}
};

if (algoName.find(algo) != algoName.end())
Expand Down Expand Up @@ -87,6 +88,9 @@ static void BM_MainEvent_Compress_LZ4(benchmark::State &state) {
static void BM_MainEvent_Compress_ZSTD(benchmark::State &state) {
BM_MainEvent_Compress(state, 5);
}
static void BM_MainEvent_Compress_FLZMA2(benchmark::State &state) {
BM_MainEvent_Compress(state, 6);
}


static void BM_MainEvent_Decompress_ZLIB(benchmark::State &state) {
Expand All @@ -101,7 +105,9 @@ static void BM_MainEvent_Decompress_LZ4(benchmark::State &state) {
static void BM_MainEvent_Decompress_ZSTD(benchmark::State &state) {
BM_MainEvent_Decompress(state, 5);
}

static void BM_MainEvent_Decompress_FLZMA2(benchmark::State &state) {
BM_MainEvent_Decompress(state, 6);
}


BENCHMARK(BM_MainEvent_Compress_ZLIB)
Expand All @@ -120,6 +126,10 @@ BENCHMARK(BM_MainEvent_Compress_ZSTD)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);

BENCHMARK(BM_MainEvent_Compress_FLZMA2)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);


BENCHMARK(BM_MainEvent_Decompress_ZLIB)
->Arg(1)->Arg(6)->Arg(9)
Expand All @@ -137,5 +147,10 @@ BENCHMARK(BM_MainEvent_Decompress_ZSTD)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);

BENCHMARK(BM_MainEvent_Decompress_FLZMA2)
->Arg(1)->Arg(6)->Arg(9)
->Unit(benchmark::kMillisecond)->Iterations(5);



BENCHMARK_MAIN();
Loading