From db3affc4278f0319e3f651ce6339e44d016d5984 Mon Sep 17 00:00:00 2001 From: kamahori Date: Mon, 17 Aug 2020 08:27:01 +0000 Subject: [PATCH 1/4] Fix io benchmarks to compress files properly --- root/io/io/TFile_ATLAS_Benchmarks.cxx | 73 ++++++----------------- root/io/io/TFile_LHCb_Benchmarks.cxx | 77 ++++++------------------- root/io/io/TFile_NanoAOD_Benchmarks.cxx | 73 ++++++----------------- 3 files changed, 51 insertions(+), 172 deletions(-) diff --git a/root/io/io/TFile_ATLAS_Benchmarks.cxx b/root/io/io/TFile_ATLAS_Benchmarks.cxx index d7c94d93..841baffa 100644 --- a/root/io/io/TFile_ATLAS_Benchmarks.cxx +++ b/root/io/io/TFile_ATLAS_Benchmarks.cxx @@ -1,5 +1,6 @@ #include "TFile.h" #include "TTree.h" +#include "TSystem.h" #include "benchmark/benchmark.h" #include "rootbench/RBConfig.h" @@ -20,38 +21,22 @@ static std::string GetAlgoName(int algo) { return "error"; } -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"); +static void BM_ATLAS_Decompress(benchmark::State &state, int algo) { 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(); - newfile->SetCompressionAlgorithm(algo); - newfile->SetCompressionLevel(comp_level); + std::string comp_setting = std::to_string(algo * 100 + comp_level); + std::string old_filename = (RB::GetDataDir() + "/gg_data-zstd.root").c_str(); + std::string new_filename = "level_" + std::to_string(comp_level) + "_atlas_" + GetAlgoName(algo) + ".root"; - state.ResumeTiming(); - newfile->Write(); - state.PauseTiming(); - - state.counters["comp_size"] = newfile->GetBytesWritten(); - newfile->Close(); - - state.ResumeTiming(); - } -} + gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); -static void BM_ATLAS_Decompress(benchmark::State &state, int algo) { - int comp_level = state.range(0); + TFile *newfile = new TFile(new_filename.c_str()); + state.counters["comp_size"] = newfile->GetSize(); + newfile->Close(); - std::string filename = "level_" + std::to_string(comp_level) + "_atlas_" + GetAlgoName(algo) + ".root"; for (auto _ : state) { - TFile *hfile = new TFile(filename.c_str()); + + TFile *hfile = new TFile(new_filename.c_str()); TTree *tree = (TTree*)hfile->Get("mini"); Int_t nevent = (Int_t)tree->GetEntries(); @@ -62,22 +47,15 @@ static void BM_ATLAS_Decompress(benchmark::State &state, int algo) { for (ev = 0; ev < nevent; ev++) { nb += tree->GetEntry(ev); } + + hfile->Close(); + } -} -static void BM_ATLAS_Compress_ZLIB(benchmark::State &state) { - BM_ATLAS_Compress(state, 1); -} -static void BM_ATLAS_Compress_LZMA(benchmark::State &state) { - BM_ATLAS_Compress(state, 2); -} -static void BM_ATLAS_Compress_LZ4(benchmark::State &state) { - BM_ATLAS_Compress(state, 4); -} -static void BM_ATLAS_Compress_ZSTD(benchmark::State &state) { - BM_ATLAS_Compress(state, 5); + gSystem->Exec(("rm -f " + new_filename).c_str()); } + static void BM_ATLAS_Decompress_ZLIB(benchmark::State &state) { BM_ATLAS_Decompress(state, 1); } @@ -92,23 +70,6 @@ static void BM_ATLAS_Decompress_ZSTD(benchmark::State &state) { } -BENCHMARK(BM_ATLAS_Compress_ZLIB) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_ATLAS_Compress_LZMA) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_ATLAS_Compress_LZ4) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_ATLAS_Compress_ZSTD) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - - BENCHMARK(BM_ATLAS_Decompress_ZLIB) ->Arg(1)->Arg(6)->Arg(9) ->Unit(benchmark::kMillisecond)->Iterations(5); @@ -126,4 +87,4 @@ BENCHMARK(BM_ATLAS_Decompress_ZSTD) ->Unit(benchmark::kMillisecond)->Iterations(5); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); \ No newline at end of file diff --git a/root/io/io/TFile_LHCb_Benchmarks.cxx b/root/io/io/TFile_LHCb_Benchmarks.cxx index 5e1e026c..3fa13e3b 100644 --- a/root/io/io/TFile_LHCb_Benchmarks.cxx +++ b/root/io/io/TFile_LHCb_Benchmarks.cxx @@ -1,5 +1,6 @@ #include "TFile.h" #include "TTree.h" +#include "TSystem.h" #include "benchmark/benchmark.h" #include "rootbench/RBConfig.h" @@ -20,42 +21,22 @@ static std::string GetAlgoName(int algo) { return "error"; } -static void BM_LHCb_Compress(benchmark::State &state, int algo) { - TFile *oldfile = new TFile((RB::GetDataDir() + "/lhcb_B2ppKK2011_md_noPIDstrip.root").c_str()); - TTree *oldtree1 = (TTree*)oldfile->Get("TupleB2ppKK/DecayTree"); - TTree *oldtree2 = (TTree*)oldfile->Get("TupleB2ppKPi/DecayTree"); - TTree *oldtree3 = (TTree*)oldfile->Get("TupleB2ppPiPi/DecayTree"); +static void BM_LHCb_Decompress(benchmark::State &state, int algo) { int comp_level = state.range(0); - std::string filename = "level_" + std::to_string(comp_level) + "_lhcb_" + GetAlgoName(algo) + ".root"; - - for (auto _ : state) { - state.PauseTiming(); - - TFile *newfile = new TFile(filename.c_str(), "recreate"); - TTree *newtree1 = oldtree1->CloneTree(); - TTree *newtree2 = oldtree2->CloneTree(); - TTree *newtree3 = oldtree3->CloneTree(); - newfile->SetCompressionAlgorithm(algo); - newfile->SetCompressionLevel(comp_level); + std::string comp_setting = std::to_string(algo * 100 + comp_level); + std::string old_filename = (RB::GetDataDir() + "/lhcb_B2ppKK2011_md_noPIDstrip.root").c_str(); + std::string new_filename = "level_" + std::to_string(comp_level) + "_lhcb_" + GetAlgoName(algo) + ".root"; - state.ResumeTiming(); - newfile->Write(); - state.PauseTiming(); + gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); - state.counters["comp_size"] = newfile->GetBytesWritten(); - newfile->Close(); + TFile *newfile = new TFile(new_filename.c_str()); + state.counters["comp_size"] = newfile->GetSize(); + newfile->Close(); - state.ResumeTiming(); - } -} - -static void BM_LHCb_Decompress(benchmark::State &state, int algo) { - int comp_level = state.range(0); - - std::string filename = "level_" + std::to_string(comp_level) + "_lhcb_" + GetAlgoName(algo) + ".root"; for (auto _ : state) { - TFile *hfile = new TFile(filename.c_str()); + + TFile *hfile = new TFile(new_filename.c_str()); TTree *tree1 = (TTree*)hfile->Get("TupleB2ppKK/DecayTree"); TTree *tree2 = (TTree*)hfile->Get("TupleB2ppKPi/DecayTree"); TTree *tree3 = (TTree*)hfile->Get("TupleB2ppPiPi/DecayTree"); @@ -78,22 +59,15 @@ static void BM_LHCb_Decompress(benchmark::State &state, int algo) { for (ev = 0; ev < nevent3; ev++) { nb += tree3->GetEntry(ev); } + + hfile->Close(); + } -} -static void BM_LHCb_Compress_ZLIB(benchmark::State &state) { - BM_LHCb_Compress(state, 1); -} -static void BM_LHCb_Compress_LZMA(benchmark::State &state) { - BM_LHCb_Compress(state, 2); -} -static void BM_LHCb_Compress_LZ4(benchmark::State &state) { - BM_LHCb_Compress(state, 4); -} -static void BM_LHCb_Compress_ZSTD(benchmark::State &state) { - BM_LHCb_Compress(state, 5); + gSystem->Exec(("rm -f " + new_filename).c_str()); } + static void BM_LHCb_Decompress_ZLIB(benchmark::State &state) { BM_LHCb_Decompress(state, 1); } @@ -108,23 +82,6 @@ static void BM_LHCb_Decompress_ZSTD(benchmark::State &state) { } -BENCHMARK(BM_LHCb_Compress_ZLIB) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_LHCb_Compress_LZMA) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_LHCb_Compress_LZ4) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_LHCb_Compress_ZSTD) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - - BENCHMARK(BM_LHCb_Decompress_ZLIB) ->Arg(1)->Arg(6)->Arg(9) ->Unit(benchmark::kMillisecond)->Iterations(5); @@ -142,4 +99,4 @@ BENCHMARK(BM_LHCb_Decompress_ZSTD) ->Unit(benchmark::kMillisecond)->Iterations(5); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); \ No newline at end of file diff --git a/root/io/io/TFile_NanoAOD_Benchmarks.cxx b/root/io/io/TFile_NanoAOD_Benchmarks.cxx index 701a6da5..670a05ad 100644 --- a/root/io/io/TFile_NanoAOD_Benchmarks.cxx +++ b/root/io/io/TFile_NanoAOD_Benchmarks.cxx @@ -1,5 +1,6 @@ #include "TFile.h" #include "TTree.h" +#include "TSystem.h" #include "benchmark/benchmark.h" #include "rootbench/RBConfig.h" @@ -20,38 +21,22 @@ static std::string GetAlgoName(int algo) { return "error"; } -static void BM_NanoAOD_Compress(benchmark::State &state, int algo) { - TFile *oldfile = new TFile((RB::GetDataDir() + "/Run2012B_DoubleMuParked.root").c_str()); - TTree *oldtree = (TTree*)oldfile->Get("Events"); +static void BM_NanoAOD_Decompress(benchmark::State &state, int algo) { int comp_level = state.range(0); - std::string filename = "level_" + std::to_string(comp_level) + "_nanoaod_" + GetAlgoName(algo) + ".root"; - - for (auto _ : state) { - state.PauseTiming(); - - TFile *newfile = new TFile(filename.c_str(), "recreate"); - TTree *newtree = oldtree->CloneTree(); - newfile->SetCompressionAlgorithm(algo); - newfile->SetCompressionLevel(comp_level); + std::string comp_setting = std::to_string(algo * 100 + comp_level); + std::string old_filename = (RB::GetDataDir() + "/Run2012B_DoubleMuParked.root").c_str(); + std::string new_filename = "level_" + std::to_string(comp_level) + "_nanoaod_" + GetAlgoName(algo) + ".root"; - state.ResumeTiming(); - newfile->Write(); - state.PauseTiming(); + gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); - state.counters["comp_size"] = newfile->GetBytesWritten(); - newfile->Close(); + TFile *newfile = new TFile(new_filename.c_str()); + state.counters["comp_size"] = newfile->GetSize(); + newfile->Close(); - state.ResumeTiming(); - } -} - -static void BM_NanoAOD_Decompress(benchmark::State &state, int algo) { - int comp_level = state.range(0); - - std::string filename = "level_" + std::to_string(comp_level) + "_nanoaod_" + GetAlgoName(algo) + ".root"; for (auto _ : state) { - TFile *hfile = new TFile(filename.c_str()); + + TFile *hfile = new TFile(new_filename.c_str()); TTree *tree = (TTree*)hfile->Get("Events"); Int_t nevent = (Int_t)tree->GetEntries(); @@ -62,22 +47,15 @@ static void BM_NanoAOD_Decompress(benchmark::State &state, int algo) { for (ev = 0; ev < nevent; ev++) { nb += tree->GetEntry(ev); } + + hfile->Close(); + } -} -static void BM_NanoAOD_Compress_ZLIB(benchmark::State &state) { - BM_NanoAOD_Compress(state, 1); -} -static void BM_NanoAOD_Compress_LZMA(benchmark::State &state) { - BM_NanoAOD_Compress(state, 2); -} -static void BM_NanoAOD_Compress_LZ4(benchmark::State &state) { - BM_NanoAOD_Compress(state, 4); -} -static void BM_NanoAOD_Compress_ZSTD(benchmark::State &state) { - BM_NanoAOD_Compress(state, 5); + gSystem->Exec(("rm -f " + new_filename).c_str()); } + static void BM_NanoAOD_Decompress_ZLIB(benchmark::State &state) { BM_NanoAOD_Decompress(state, 1); } @@ -92,23 +70,6 @@ static void BM_NanoAOD_Decompress_ZSTD(benchmark::State &state) { } -BENCHMARK(BM_NanoAOD_Compress_ZLIB) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_NanoAOD_Compress_LZMA) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_NanoAOD_Compress_LZ4) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - -BENCHMARK(BM_NanoAOD_Compress_ZSTD) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); - - BENCHMARK(BM_NanoAOD_Decompress_ZLIB) ->Arg(1)->Arg(6)->Arg(9) ->Unit(benchmark::kMillisecond)->Iterations(5); @@ -126,4 +87,4 @@ BENCHMARK(BM_NanoAOD_Decompress_ZSTD) ->Unit(benchmark::kMillisecond)->Iterations(5); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); \ No newline at end of file From 42519e8e0119bada51e59e2bc752408a5f1ccd08 Mon Sep 17 00:00:00 2001 From: kamahori Date: Wed, 19 Aug 2020 12:13:26 +0000 Subject: [PATCH 2/4] Change files and number of iterations to save time --- root/io/io/CMakeLists.txt | 33 ++++++------- root/io/io/TFile_ATLAS_Benchmarks.cxx | 65 ++++++++++++++++++------- root/io/io/TFile_LHCb_Benchmarks.cxx | 8 +-- root/io/io/TFile_NanoAOD_Benchmarks.cxx | 10 ++-- 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/root/io/io/CMakeLists.txt b/root/io/io/CMakeLists.txt index bfc77c8c..69d8b140 100644 --- a/root/io/io/CMakeLists.txt +++ b/root/io/io/CMakeLists.txt @@ -15,22 +15,21 @@ if(rootbench-datafiles) LIBRARIES Core RIO DOWNLOAD_DATAFILES Event0-sample.root) - # 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 + 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 + DOWNLOAD_DATAFILES Run2012B_DoubleElectron.root) - #RB_ADD_GBENCHMARK(CompressionBenchmarks_ATLAS - # TFile_ATLAS_Benchmarks.cxx - # LABEL short - # LIBRARIES Core RIO - # DOWNLOAD_DATAFILES gg_data-zstd.root) -endif() + RB_ADD_GBENCHMARK(CompressionBenchmarks_ATLAS + TFile_ATLAS_Benchmarks.cxx + LABEL short + LIBRARIES Core RIO + DOWNLOAD_DATAFILES atlasopendata_mc_117050.ttbar_lep.root atlasopendata_DataMuons.root) +endif() \ No newline at end of file diff --git a/root/io/io/TFile_ATLAS_Benchmarks.cxx b/root/io/io/TFile_ATLAS_Benchmarks.cxx index 841baffa..685ba080 100644 --- a/root/io/io/TFile_ATLAS_Benchmarks.cxx +++ b/root/io/io/TFile_ATLAS_Benchmarks.cxx @@ -21,11 +21,11 @@ static std::string GetAlgoName(int algo) { return "error"; } -static void BM_ATLAS_Decompress(benchmark::State &state, int algo) { +static void BM_ATLAS_Decompress(benchmark::State &state, int algo, std::string filename) { int comp_level = state.range(0); std::string comp_setting = std::to_string(algo * 100 + comp_level); - std::string old_filename = (RB::GetDataDir() + "/gg_data-zstd.root").c_str(); + std::string old_filename = (RB::GetDataDir() + "/" + filename + ".root").c_str(); std::string new_filename = "level_" + std::to_string(comp_level) + "_atlas_" + GetAlgoName(algo) + ".root"; gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); @@ -56,35 +56,64 @@ static void BM_ATLAS_Decompress(benchmark::State &state, int algo) { } -static void BM_ATLAS_Decompress_ZLIB(benchmark::State &state) { - BM_ATLAS_Decompress(state, 1); +static void BM_ATLAS_Decompress_Real_ZLIB(benchmark::State &state) { + BM_ATLAS_Decompress(state, 1, "atlasopendata_DataMuons"); } -static void BM_ATLAS_Decompress_LZMA(benchmark::State &state) { - BM_ATLAS_Decompress(state, 2); +static void BM_ATLAS_Decompress_Real_LZMA(benchmark::State &state) { + BM_ATLAS_Decompress(state, 2, "atlasopendata_DataMuons"); } -static void BM_ATLAS_Decompress_LZ4(benchmark::State &state) { - BM_ATLAS_Decompress(state, 4); +static void BM_ATLAS_Decompress_Real_LZ4(benchmark::State &state) { + BM_ATLAS_Decompress(state, 4, "atlasopendata_DataMuons"); } -static void BM_ATLAS_Decompress_ZSTD(benchmark::State &state) { - BM_ATLAS_Decompress(state, 5); +static void BM_ATLAS_Decompress_Real_ZSTD(benchmark::State &state) { + BM_ATLAS_Decompress(state, 5, "atlasopendata_DataMuons"); } +BENCHMARK(BM_ATLAS_Decompress_Real_ZLIB) +->Arg(1)->Arg(6)->Arg(9) +->Unit(benchmark::kMillisecond)->Iterations(3); + +BENCHMARK(BM_ATLAS_Decompress_Real_LZMA) +->Arg(1)->Arg(6)->Arg(9) +->Unit(benchmark::kMillisecond)->Iterations(3); + +BENCHMARK(BM_ATLAS_Decompress_Real_LZ4) +->Arg(1)->Arg(6)->Arg(9) +->Unit(benchmark::kMillisecond)->Iterations(3); + +BENCHMARK(BM_ATLAS_Decompress_Real_ZSTD) +->Arg(1)->Arg(6)->Arg(9) +->Unit(benchmark::kMillisecond)->Iterations(3); + + +static void BM_ATLAS_Decompress_MC_ZLIB(benchmark::State &state) { + BM_ATLAS_Decompress(state, 1, "atlasopendata_mc_117050.ttbar_lep"); +} +static void BM_ATLAS_Decompress_MC_LZMA(benchmark::State &state) { + BM_ATLAS_Decompress(state, 2, "atlasopendata_mc_117050.ttbar_lep"); +} +static void BM_ATLAS_Decompress_MC_LZ4(benchmark::State &state) { + BM_ATLAS_Decompress(state, 4, "atlasopendata_mc_117050.ttbar_lep"); +} +static void BM_ATLAS_Decompress_MC_ZSTD(benchmark::State &state) { + BM_ATLAS_Decompress(state, 5, "atlasopendata_mc_117050.ttbar_lep"); +} -BENCHMARK(BM_ATLAS_Decompress_ZLIB) +BENCHMARK(BM_ATLAS_Decompress_MC_ZLIB) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); -BENCHMARK(BM_ATLAS_Decompress_LZMA) +BENCHMARK(BM_ATLAS_Decompress_MC_LZMA) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); -BENCHMARK(BM_ATLAS_Decompress_LZ4) +BENCHMARK(BM_ATLAS_Decompress_MC_LZ4) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); -BENCHMARK(BM_ATLAS_Decompress_ZSTD) +BENCHMARK(BM_ATLAS_Decompress_MC_ZSTD) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK_MAIN(); \ No newline at end of file diff --git a/root/io/io/TFile_LHCb_Benchmarks.cxx b/root/io/io/TFile_LHCb_Benchmarks.cxx index 3fa13e3b..5fe2fe6a 100644 --- a/root/io/io/TFile_LHCb_Benchmarks.cxx +++ b/root/io/io/TFile_LHCb_Benchmarks.cxx @@ -84,19 +84,19 @@ static void BM_LHCb_Decompress_ZSTD(benchmark::State &state) { BENCHMARK(BM_LHCb_Decompress_ZLIB) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK(BM_LHCb_Decompress_LZMA) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK(BM_LHCb_Decompress_LZ4) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK(BM_LHCb_Decompress_ZSTD) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK_MAIN(); \ No newline at end of file diff --git a/root/io/io/TFile_NanoAOD_Benchmarks.cxx b/root/io/io/TFile_NanoAOD_Benchmarks.cxx index 670a05ad..8eee5341 100644 --- a/root/io/io/TFile_NanoAOD_Benchmarks.cxx +++ b/root/io/io/TFile_NanoAOD_Benchmarks.cxx @@ -25,7 +25,7 @@ static void BM_NanoAOD_Decompress(benchmark::State &state, int algo) { int comp_level = state.range(0); std::string comp_setting = std::to_string(algo * 100 + comp_level); - std::string old_filename = (RB::GetDataDir() + "/Run2012B_DoubleMuParked.root").c_str(); + std::string old_filename = (RB::GetDataDir() + "/Run2012B_DoubleElectron.root").c_str(); std::string new_filename = "level_" + std::to_string(comp_level) + "_nanoaod_" + GetAlgoName(algo) + ".root"; gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); @@ -72,19 +72,19 @@ static void BM_NanoAOD_Decompress_ZSTD(benchmark::State &state) { BENCHMARK(BM_NanoAOD_Decompress_ZLIB) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK(BM_NanoAOD_Decompress_LZMA) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK(BM_NanoAOD_Decompress_LZ4) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK(BM_NanoAOD_Decompress_ZSTD) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(5); +->Unit(benchmark::kMillisecond)->Iterations(3); BENCHMARK_MAIN(); \ No newline at end of file From b3c6f4d15fabc242f16941b9bfcc42d44dd3c1c9 Mon Sep 17 00:00:00 2001 From: kamahori Date: Thu, 20 Aug 2020 12:10:52 +0000 Subject: [PATCH 3/4] Use RB::GetTempFs() --- root/io/io/TFile_ATLAS_Benchmarks.cxx | 2 +- root/io/io/TFile_LHCb_Benchmarks.cxx | 2 +- root/io/io/TFile_NanoAOD_Benchmarks.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/root/io/io/TFile_ATLAS_Benchmarks.cxx b/root/io/io/TFile_ATLAS_Benchmarks.cxx index 685ba080..e8b542c4 100644 --- a/root/io/io/TFile_ATLAS_Benchmarks.cxx +++ b/root/io/io/TFile_ATLAS_Benchmarks.cxx @@ -26,7 +26,7 @@ static void BM_ATLAS_Decompress(benchmark::State &state, int algo, std::string f int comp_level = state.range(0); std::string comp_setting = std::to_string(algo * 100 + comp_level); std::string old_filename = (RB::GetDataDir() + "/" + filename + ".root").c_str(); - std::string new_filename = "level_" + std::to_string(comp_level) + "_atlas_" + GetAlgoName(algo) + ".root"; + std::string new_filename = (RB::GetTempFs() + "level_" + std::to_string(comp_level) + "_atlas_" + GetAlgoName(algo) + ".root").c_str(); gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); diff --git a/root/io/io/TFile_LHCb_Benchmarks.cxx b/root/io/io/TFile_LHCb_Benchmarks.cxx index 5fe2fe6a..7be6aca2 100644 --- a/root/io/io/TFile_LHCb_Benchmarks.cxx +++ b/root/io/io/TFile_LHCb_Benchmarks.cxx @@ -26,7 +26,7 @@ static void BM_LHCb_Decompress(benchmark::State &state, int algo) { int comp_level = state.range(0); std::string comp_setting = std::to_string(algo * 100 + comp_level); std::string old_filename = (RB::GetDataDir() + "/lhcb_B2ppKK2011_md_noPIDstrip.root").c_str(); - std::string new_filename = "level_" + std::to_string(comp_level) + "_lhcb_" + GetAlgoName(algo) + ".root"; + std::string new_filename = (RB::GetTempFs() + "level_" + std::to_string(comp_level) + "_lhcb_" + GetAlgoName(algo) + ".root"); gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); diff --git a/root/io/io/TFile_NanoAOD_Benchmarks.cxx b/root/io/io/TFile_NanoAOD_Benchmarks.cxx index 8eee5341..17a7fbdc 100644 --- a/root/io/io/TFile_NanoAOD_Benchmarks.cxx +++ b/root/io/io/TFile_NanoAOD_Benchmarks.cxx @@ -26,7 +26,7 @@ static void BM_NanoAOD_Decompress(benchmark::State &state, int algo) { int comp_level = state.range(0); std::string comp_setting = std::to_string(algo * 100 + comp_level); std::string old_filename = (RB::GetDataDir() + "/Run2012B_DoubleElectron.root").c_str(); - std::string new_filename = "level_" + std::to_string(comp_level) + "_nanoaod_" + GetAlgoName(algo) + ".root"; + std::string new_filename = (RB::GetTempFs() + "level_" + std::to_string(comp_level) + "_nanoaod_" + GetAlgoName(algo) + ".root").c_str(); gSystem->Exec(("hadd -v 0 -f" + comp_setting + " " + new_filename + " " + old_filename).c_str()); From 8e9705d85fb21c7fd323352626d2020556432c2e Mon Sep 17 00:00:00 2001 From: kamahori Date: Mon, 31 Aug 2020 14:35:38 +0000 Subject: [PATCH 4/4] Remove ATLAS Real BM and reduce iterations to 2 --- root/io/io/CMakeLists.txt | 2 +- root/io/io/TFile_ATLAS_Benchmarks.cxx | 41 +++++---------------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/root/io/io/CMakeLists.txt b/root/io/io/CMakeLists.txt index 69d8b140..aa515293 100644 --- a/root/io/io/CMakeLists.txt +++ b/root/io/io/CMakeLists.txt @@ -31,5 +31,5 @@ if(rootbench-datafiles) TFile_ATLAS_Benchmarks.cxx LABEL short LIBRARIES Core RIO - DOWNLOAD_DATAFILES atlasopendata_mc_117050.ttbar_lep.root atlasopendata_DataMuons.root) + DOWNLOAD_DATAFILES atlasopendata_mc_117050.ttbar_lep.root) endif() \ No newline at end of file diff --git a/root/io/io/TFile_ATLAS_Benchmarks.cxx b/root/io/io/TFile_ATLAS_Benchmarks.cxx index e8b542c4..3393fcba 100644 --- a/root/io/io/TFile_ATLAS_Benchmarks.cxx +++ b/root/io/io/TFile_ATLAS_Benchmarks.cxx @@ -55,36 +55,9 @@ static void BM_ATLAS_Decompress(benchmark::State &state, int algo, std::string f gSystem->Exec(("rm -f " + new_filename).c_str()); } - -static void BM_ATLAS_Decompress_Real_ZLIB(benchmark::State &state) { - BM_ATLAS_Decompress(state, 1, "atlasopendata_DataMuons"); -} -static void BM_ATLAS_Decompress_Real_LZMA(benchmark::State &state) { - BM_ATLAS_Decompress(state, 2, "atlasopendata_DataMuons"); -} -static void BM_ATLAS_Decompress_Real_LZ4(benchmark::State &state) { - BM_ATLAS_Decompress(state, 4, "atlasopendata_DataMuons"); -} -static void BM_ATLAS_Decompress_Real_ZSTD(benchmark::State &state) { - BM_ATLAS_Decompress(state, 5, "atlasopendata_DataMuons"); -} - -BENCHMARK(BM_ATLAS_Decompress_Real_ZLIB) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); - -BENCHMARK(BM_ATLAS_Decompress_Real_LZMA) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); - -BENCHMARK(BM_ATLAS_Decompress_Real_LZ4) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); - -BENCHMARK(BM_ATLAS_Decompress_Real_ZSTD) -->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); - +// Benchmarks for ATLAS files of experimental (real) data are deleted +// because it takes very long time. +// TODO: find smaller file static void BM_ATLAS_Decompress_MC_ZLIB(benchmark::State &state) { BM_ATLAS_Decompress(state, 1, "atlasopendata_mc_117050.ttbar_lep"); @@ -101,19 +74,19 @@ static void BM_ATLAS_Decompress_MC_ZSTD(benchmark::State &state) { BENCHMARK(BM_ATLAS_Decompress_MC_ZLIB) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); +->Unit(benchmark::kMillisecond)->Iterations(2); BENCHMARK(BM_ATLAS_Decompress_MC_LZMA) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); +->Unit(benchmark::kMillisecond)->Iterations(2); BENCHMARK(BM_ATLAS_Decompress_MC_LZ4) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); +->Unit(benchmark::kMillisecond)->Iterations(2); BENCHMARK(BM_ATLAS_Decompress_MC_ZSTD) ->Arg(1)->Arg(6)->Arg(9) -->Unit(benchmark::kMillisecond)->Iterations(3); +->Unit(benchmark::kMillisecond)->Iterations(2); BENCHMARK_MAIN(); \ No newline at end of file