Skip to content

Commit 4d8eb60

Browse files
committed
[df] Change default Snapshot compression settings
The default Snapshot compression setting has always been 101. Historically, this was done for simplicity reasons and following the principle of least surprise. TTree was the only output format available with Snapshot, so the operation was defaulting to the same value used by TTree. Now that Snapshot supports more than one output format, this reason is less strong than before. It has been established that 505 is a better default compression setting overall, so RDataFrame should follow that. The main disadvantage is that this change is hard to communicate. This commit proposes to introduce an information message being shown once per program execution, and only if the program is calling Snapshot. This message is supposed to help the users detect changes in their output file size with the next development cycle (6.38.x) and should be removed afterwards.
1 parent ffdab66 commit 4d8eb60

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

README/ReleaseNotes/v638/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ If you want to keep using `TList*` return values, you can write a small adapter
134134
RDF uses one copy of each histogram per thread. Now, RDataFrame can reduce the number of clones using `ROOT::RDF::Experimental::ThreadsPerTH3()`. Setting this
135135
to numbers such as 8 would share one 3-d histogram among 8 threads, greatly reducing the memory consumption. This might slow down execution if the histograms
136136
are filled at very high rates. Use lower number in this case.
137-
- The Snapshot method has been refactored so that it does not need anymore compile-time information (i.e. either template arguments or JIT-ting) to know the input column types. This means that any Snapshot call that specifies the template arguments, e.g. `Snapshot<int, float>(..., {"intCol", "floatCol"})` is now redundant and the template arguments can safely be removed from the call. At the same time, Snapshot does not need to JIT compile the column types, practically giving huge speedups depending on the number of columns that need to be written to disk. In certain cases (e.g. when writing O(10000) columns) the speedup can be larger than an order of magnitude. The Snapshot template is now deprecated and it will issue a compile-time warning when called. The function overload is scheduled for removal in ROOT 6.40.
138137
- Add HistoNSparseD action that fills a sparse N-dimensional histogram.
139138

139+
### Snapshot
140+
- The Snapshot method has been refactored so that it does not need anymore compile-time information (i.e. either template arguments or JIT-ting) to know the input column types. This means that any Snapshot call that specifies the template arguments, e.g. `Snapshot<int, float>(..., {"intCol", "floatCol"})` is now redundant and the template arguments can safely be removed from the call. At the same time, Snapshot does not need to JIT compile the column types, practically giving huge speedups depending on the number of columns that need to be written to disk. In certain cases (e.g. when writing O(10000) columns) the speedup can be larger than an order of magnitude. The Snapshot template is now deprecated and it will issue a compile-time warning when called. The function overload is scheduled for removal in ROOT 6.40.
141+
- The default compression setting for the output dataset used by Snapshot has been changed from 101 (ZLIB level 1, the TTree default) to 505 (ZSTD level 5). This is a better setting on average, and makes more sense for RDataFrame since now the Snapshot operation supports more than just the TTree output data format. This change may result in smaller output file sizes for your analyses that use Snapshot with default settings. During the 6.38 development release cycle, Snapshot will print information about this change once per program run. Starting from 6.40.00, the information will not be printed. The message can be suppressed by setting ROOT_RDF_SILENCE_SNAPSHOT_INFO=1 in your environment or by setting 'ROOT.RDF.Snapshot.Info: 0' in your .rootrc.
142+
140143
## Python Interface
141144

142145
ROOT dropped support for Python 3.8, meaning ROOT now requires at least Python 3.9.

config/rootrc.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,3 +615,9 @@ Rint.Canvas.HighLightColor: 5
615615
# 1 All Branches (default)
616616
# Can be overridden by the environment variable ROOT_TTREECACHE_PREFILL
617617
# TTreeCache.Prefill: 1
618+
619+
# Set whether to show or suppress an info message coming from RDataFrame
620+
# Snapshot informing the user on the change of default output dataset
621+
# compression settings introduced in ROOT 6.38 (1 means show the info, 0 means
622+
# suppress, 1 by default).
623+
# ROOT.RDF.Snapshot.Info: 1

roottest/root/dataframe/.rootrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# First two lines are taken from ROOTTEST_ADD_TESTDIRS in RootMacros.cmake
2+
Rint.History: .root_hist
3+
ACLiC.LinkLibs: 1
4+
# Suppress the info message from Snapshot to prevent test failures
5+
ROOT.RDF.Snapshot.Info: 0

tree/dataframe/inc/ROOT/RDF/RInterface.hxx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
#include "TProfile2D.h"
4646
#include "TStatistic.h"
4747

48+
// TODO: Needed to show the info message in Snapshot, remove in 6.40
49+
#include "ROOT/RLogger.hxx"
50+
#include "ROOT/RVersion.hxx"
51+
#include "TEnv.h"
52+
#include <cstdlib>
53+
#include <cstring>
54+
4855
#include <algorithm>
4956
#include <cstddef>
5057
#include <initializer_list>
@@ -1332,6 +1339,26 @@ public:
13321339
const ColumnNames_t &columnList,
13331340
const RSnapshotOptions &options = RSnapshotOptions())
13341341
{
1342+
// TODO: Remove before releasing 6.40.00
1343+
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 40, 0)
1344+
static_assert(false && "Remove information about change of Snapshot defaut compression settings.");
1345+
#endif
1346+
[[maybe_unused]] static bool once = []() {
1347+
if (const char *suppress = std::getenv("ROOT_RDF_SNAPSHOT_INFO"))
1348+
if (std::strcmp(suppress, "0") == 0)
1349+
return true;
1350+
if (const char *suppress = gEnv->GetValue("ROOT.RDF.Snapshot.Info", "1"))
1351+
if (std::strcmp(suppress, "0") == 0)
1352+
return true;
1353+
RLogScopedVerbosity showInfo{ROOT::Detail::RDF::RDFLogChannel(), ROOT::ELogLevel::kInfo};
1354+
R__LOG_INFO(ROOT::Detail::RDF::RDFLogChannel())
1355+
<< "\n\tIn ROOT 6.38, the default compression settings of Snapshot have been changed from 101 (ZLIB with "
1356+
"compression level 1, the TTree default) to 505 (ZSTD with compression level 5). This change may result "
1357+
"in smaller Snapshot output dataset size by default. In order to suppress this message, set "
1358+
"'ROOT_RDF_SNAPSHOT_INFO=0' in your environment or set 'ROOT.RDF.Snapshot.Info: 0' in your .rootrc "
1359+
"file.";
1360+
return true;
1361+
}();
13351362
// like columnList but with `#var` columns removed
13361363
auto colListNoPoundSizes = RDFInternal::FilterArraySizeColNames(columnList, "Snapshot");
13371364
// like columnListWithoutSizeColumns but with aliases resolved

tree/dataframe/inc/ROOT/RSnapshotOptions.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct RSnapshotOptions {
4646
}
4747
std::string fMode = "RECREATE"; ///< Mode of creation of output file
4848
ECAlgo fCompressionAlgorithm =
49-
ROOT::RCompressionSetting::EAlgorithm::kZLIB; ///< Compression algorithm of output file
50-
int fCompressionLevel = 1; ///< Compression level of output file
49+
ROOT::RCompressionSetting::EAlgorithm::kZSTD; ///< Compression algorithm of output file
50+
int fCompressionLevel = 5; ///< Compression level of output file
5151
int fAutoFlush = 0; ///< AutoFlush value for output tree
5252
int fSplitLevel = 99; ///< Split level of output tree
5353
bool fLazy = false; ///< Do not start the event loop when Snapshot is called

0 commit comments

Comments
 (0)