Skip to content

Commit

Permalink
[ntuple] remove "cluster bunch size" from public read options
Browse files Browse the repository at this point in the history
This option has been useful for performance studies. It specifies the
number of clusters to be preloaded in the cluster cache. Since the size
of clusters is a priori unknown, this option is not well suited as a
general interface. Eventually, the option will be replaced by a prefetch
setting based on available memory ("prefill at max x MB").
  • Loading branch information
jblomer committed Jan 30, 2025
1 parent c31714f commit 98150c8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tree/dataframe/src/RNTupleDS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ const ROOT::Experimental::RNTupleReadOptions &GetOpts()
std::string envStr{env};
auto envNum{std::stoul(envStr)};
envNum = envNum == 0 ? 1 : envNum;
opts.SetClusterBunchSize(envNum);
Internal::RNTupleReadOptionsManip::SetClusterBunchSize(opts, envNum);
}
});
return opts;
Expand Down
31 changes: 28 additions & 3 deletions tree/ntuple/v7/inc/ROOT/RNTupleReadOptions.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
namespace ROOT {
namespace Experimental {

class RNTupleReadOptions;

namespace Internal {

class RNTupleReadOptionsManip final {
public:
static unsigned int GetClusterBunchSize(const RNTupleReadOptions &options);
static void SetClusterBunchSize(RNTupleReadOptions &options, unsigned int val);
};

} // namespace Internal

// clang-format off
/**
\class ROOT::Experimental::RNTupleReadOptions
Expand All @@ -29,6 +41,8 @@ All page source classes need to support the common options.
*/
// clang-format on
class RNTupleReadOptions {
friend class Internal::RNTupleReadOptionsManip;

public:
enum class EClusterCache {
kOff,
Expand All @@ -52,16 +66,27 @@ public:
EClusterCache GetClusterCache() const { return fClusterCache; }
void SetClusterCache(EClusterCache val) { fClusterCache = val; }

unsigned int GetClusterBunchSize() const { return fClusterBunchSize; }
void SetClusterBunchSize(unsigned int val) { fClusterBunchSize = val; }

EImplicitMT GetUseImplicitMT() const { return fUseImplicitMT; }
void SetUseImplicitMT(EImplicitMT val) { fUseImplicitMT = val; }

bool HasMetricsEnabled() const { return fEnableMetrics; }
void SetMetricsEnabled(bool enable) { fEnableMetrics = enable; }
};

namespace Internal {

inline unsigned int RNTupleReadOptionsManip::GetClusterBunchSize(const RNTupleReadOptions &options)
{
return options.fClusterBunchSize;
}

inline void RNTupleReadOptionsManip::SetClusterBunchSize(RNTupleReadOptions &options, unsigned int val)
{
options.fClusterBunchSize = val;
}

} // namespace Internal

} // namespace Experimental
} // namespace ROOT

Expand Down
3 changes: 2 additions & 1 deletion tree/ntuple/v7/src/RPageStorage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ void ROOT::Experimental::Internal::RPageSource::UpdateLastUsedCluster(Descriptor
itr = fPreloadedClusters.erase(itr);
}
std::size_t poolWindow = 0;
while ((itr != fPreloadedClusters.end()) && (poolWindow < 2 * fOptions.GetClusterBunchSize())) {
while ((itr != fPreloadedClusters.end()) &&
(poolWindow < 2 * RNTupleReadOptionsManip::GetClusterBunchSize(fOptions))) {
++itr;
++poolWindow;
}
Expand Down
2 changes: 1 addition & 1 deletion tree/ntuple/v7/src/RPageStorageDaos.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ ROOT::Experimental::Internal::RPageSourceDaos::RPageSourceDaos(std::string_view
const RNTupleReadOptions &options)
: RPageSource(ntupleName, options),
fURI(uri),
fClusterPool(std::make_unique<RClusterPool>(*this, options.GetClusterBunchSize()))
fClusterPool(std::make_unique<RClusterPool>(*this, RNTupleReadOptionsManip::GetClusterBunchSize(options)))
{
EnableDefaultMetrics("RPageSourceDaos");

Expand Down
6 changes: 3 additions & 3 deletions tree/ntuple/v7/src/RPageStorageFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ void ROOT::Experimental::Internal::RPageSinkFile::CommitDatasetImpl(unsigned cha
////////////////////////////////////////////////////////////////////////////////

ROOT::Experimental::Internal::RPageSourceFile::RPageSourceFile(std::string_view ntupleName,
const RNTupleReadOptions &options)
: RPageSource(ntupleName, options),
fClusterPool(std::make_unique<RClusterPool>(*this, options.GetClusterBunchSize()))
const RNTupleReadOptions &opts)
: RPageSource(ntupleName, opts),
fClusterPool(std::make_unique<RClusterPool>(*this, Internal::RNTupleReadOptionsManip::GetClusterBunchSize(opts)))
{
EnableDefaultMetrics("RPageSourceFile");
}
Expand Down
8 changes: 4 additions & 4 deletions tree/ntuple/v7/test/ntuple_storage_daos.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ TEST_F(RPageStorageDaos, Extended)
}

RNTupleReadOptions options;
options.SetClusterBunchSize(5);
ROOT::Experimental::Internal::RNTupleReadOptionsManip::SetClusterBunchSize(options, 5);
auto ntuple = RNTupleReader::Open(ntupleName, daosUri, options);
auto rdVector = ntuple->GetModel().GetDefaultEntry().GetPtr<std::vector<double>>("vector");

Expand Down Expand Up @@ -155,11 +155,11 @@ TEST_F(RPageStorageDaos, Options)
}

auto readOptions = RNTupleReadOptions();
readOptions.SetClusterBunchSize(3);
ROOT::Experimental::Internal::RNTupleReadOptionsManip::SetClusterBunchSize(readOptions, 3);
ROOT::Experimental::Internal::RPageSourceDaos source(ntupleName, daosUri, readOptions);
source.Attach();
EXPECT_STREQ("RP_XSF", source.GetObjectClass().c_str());
EXPECT_EQ(3U, source.GetReadOptions().GetClusterBunchSize());
EXPECT_EQ(3U, ROOT::Experimental::Internal::RNTupleReadOptionsManip::GetClusterBunchSize(source.GetReadOptions()));
EXPECT_EQ(1U, source.GetNEntries());
}

Expand Down Expand Up @@ -286,7 +286,7 @@ TEST_F(RPageStorageDaos, CagedPages)
{
RNTupleReadOptions options;
options.SetClusterCache(RNTupleReadOptions::EClusterCache::kOn);
options.SetClusterBunchSize(5);
ROOT::Experimental::Internal::RNTupleReadOptionsManip::SetClusterBunchSize(options, 5);
auto ntuple = RNTupleReader::Open(ntupleName, daosUri, options);
auto rdVector = ntuple->GetModel().GetDefaultEntry().GetPtr<std::vector<double>>("vector");

Expand Down

0 comments on commit 98150c8

Please sign in to comment.