Skip to content

Commit 05f0d68

Browse files
committed
[ntuple] Expand disk visualizer backend
Adds the ntuple header, footer and page list to the method. Updates its unit test accordingly.
1 parent bd5cfd3 commit 05f0d68

5 files changed

Lines changed: 76 additions & 23 deletions

File tree

tree/ntuple/inc/ROOT/RPageStorageFile.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ namespace Internal {
4242
class RRawFile;
4343
class RPageAllocatorHeap;
4444

45+
RNTuple GetAnchor(const RPageSource &source);
46+
4547
// clang-format off
4648
/**
4749
\class ROOT::Internal::RPageSinkFile
@@ -122,6 +124,7 @@ public:
122124
// clang-format on
123125
class RPageSourceFile : public RPageSource {
124126
friend class ROOT::RNTuple;
127+
friend ROOT::RNTuple ROOT::Internal::GetAnchor(const RPageSource &);
125128

126129
private:
127130
/// Either provided by CreateFromAnchor, or read from the ROOT file given the ntuple name

tree/ntuple/src/RPageStorageFile.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ ROOT::Internal::RPageSinkFile::CloneAsHidden(std::string_view name, const ROOT::
306306

307307
////////////////////////////////////////////////////////////////////////////////
308308

309+
ROOT::RNTuple ROOT::Internal::GetAnchor(const RPageSource &source)
310+
{
311+
const auto *fileSource = dynamic_cast<const RPageSourceFile *>(&source);
312+
if (!fileSource)
313+
throw RException(R__FAIL("Cannot retrieve an RNTuple anchor from a non-file page source"));
314+
if (!fileSource->fAnchor)
315+
throw RException(R__FAIL("Cannot retrieve RNTuple anchor: no anchor is available"));
316+
return *fileSource->fAnchor;
317+
}
318+
309319
ROOT::Internal::RPageSourceFile::RPageSourceFile(std::string_view ntupleName, const ROOT::RNTupleReadOptions &opts)
310320
: RPageSource(ntupleName, opts)
311321
{

tree/ntupleutil/inc/ROOT/RNTupleInspector.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ public:
505505
void PrintSchemaProfile(ESchemaProfileFormat format, std::ostream &output = std::cout) const;
506506

507507
////////////////////////////////////////////////////////////////////////////
508-
/// \brief Print a string that represents the on-disk storage of the cluster groups, clusters, column ranges and
509-
/// pages on an RNTuple in a format which a performance profile visualizer can render
508+
/// \brief Print a string that represents the on-disk storage of the cluster groups, clusters, column ranges, pages,
509+
/// header, footer and page lists on an RNTuple in a format which a performance profile visualizer can render
510510
///
511511
/// \warning ntuple must have a file-based backend
512512
void PrintDiskProfile(ESchemaProfileFormat format, std::ostream &output = std::cout) const;

tree/ntupleutil/src/RNTupleInspector.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ void ROOT::Experimental::RNTupleInspector::PrintDiskProfile([[maybe_unused]] ESc
698698
// There is only one format at the moment
699699
assert(format == ESchemaProfileFormat::kSpeedscopeJSON);
700700

701+
// This method only supports file based backend. Will need the anchor later, but better to check early
702+
const auto anchor = ROOT::Internal::GetAnchor(*fPageSource);
703+
701704
const auto &descriptor = GetDescriptor();
702705

703706
struct RDiskPageLeaf {
@@ -753,6 +756,13 @@ void ROOT::Experimental::RNTupleInspector::PrintDiskProfile([[maybe_unused]] ESc
753756
std::vector<std::size_t> openFrameIndexes;
754757
std::uint64_t previouspageLeafEnd = 0;
755758

759+
// Construct frame for ntuple header
760+
SpeedscopeFrame headerFrame;
761+
headerFrame.fString = "ntuple header";
762+
headerFrame.fOpeningPosition = anchor.GetSeekHeader();
763+
headerFrame.fClosingPosition = anchor.GetSeekHeader() + anchor.GetNBytesHeader();
764+
frames.push_back(headerFrame);
765+
756766
// Construct frames from the bottom (leafs ordered by disk address) upwards
757767
for (const auto &pageLeaf : pageLeaves) {
758768
std::size_t sharedDepth = 0;
@@ -797,5 +807,23 @@ void ROOT::Experimental::RNTupleInspector::PrintDiskProfile([[maybe_unused]] ESc
797807
openFrameIndexes.pop_back();
798808
}
799809

810+
// Construct frames for page lists
811+
for (const auto &clusterGroupDescriptor : descriptor.GetClusterGroupIterable()) {
812+
const auto locator = clusterGroupDescriptor.GetPageListLocator();
813+
814+
SpeedscopeFrame pageListFrame;
815+
pageListFrame.fString = "[page list " + std::to_string(clusterGroupDescriptor.GetId()) + "]";
816+
pageListFrame.fOpeningPosition = locator.GetPosition<std::uint64_t>();
817+
pageListFrame.fClosingPosition = locator.GetPosition<std::uint64_t>() + locator.GetNBytesOnStorage();
818+
frames.push_back(pageListFrame);
819+
}
820+
821+
// Construct frame for ntuple footer
822+
SpeedscopeFrame footerFrame;
823+
footerFrame.fString = "ntuple footer";
824+
footerFrame.fOpeningPosition = anchor.GetSeekFooter();
825+
footerFrame.fClosingPosition = anchor.GetSeekFooter() + anchor.GetNBytesFooter();
826+
frames.push_back(footerFrame);
827+
800828
PrintSpeedscopeFrames(frames, output);
801829
}

tree/ntupleutil/test/ntuple_inspector.cxx

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ TEST(RNTupleInspector, DiskProfile)
11311131
"$schema":"https://www.speedscope.app/file-format-schema.json",
11321132
"shared":{
11331133
"frames":[
1134+
{ "name":"ntuple header" },
11341135
{ "name":"[cluster group 0]" },
11351136
{ "name":"[cluster 0]" },
11361137
{ "name":"[column range 0]" },
@@ -1153,7 +1154,10 @@ TEST(RNTupleInspector, DiskProfile)
11531154
{ "name":"[cluster group 0]" },
11541155
{ "name":"[cluster 2]" },
11551156
{ "name":"[column range 0]" },
1156-
{ "name":"[page @3208]" }
1157+
{ "name":"[page @3208]" },
1158+
{ "name":"[page list 0]" },
1159+
{ "name":"[page list 1]" },
1160+
{ "name":"ntuple footer" }
11571161
]
11581162
},
11591163
"profiles":[
@@ -1162,54 +1166,62 @@ TEST(RNTupleInspector, DiskProfile)
11621166
"name":"Flattened Timeline",
11631167
"unit":"bytes",
11641168
"startValue":0,
1165-
"endValue":3608,
1169+
"endValue":4454,
11661170
"events":[
1167-
{"type":"O","frame":0,"at":882},
1171+
{"type":"O","frame":0,"at":290},
1172+
{"type":"C","frame":0,"at":840},
11681173
{"type":"O","frame":1,"at":882},
11691174
{"type":"O","frame":2,"at":882},
11701175
{"type":"O","frame":3,"at":882},
1171-
{"type":"C","frame":3,"at":1082},
1172-
{"type":"O","frame":4,"at":1132},
1173-
{"type":"C","frame":4,"at":1232},
1174-
{"type":"C","frame":2,"at":1232},
1175-
{"type":"O","frame":5,"at":1274},
1176+
{"type":"O","frame":4,"at":882},
1177+
{"type":"C","frame":4,"at":1082},
1178+
{"type":"O","frame":5,"at":1132},
1179+
{"type":"C","frame":5,"at":1232},
1180+
{"type":"C","frame":3,"at":1232},
11761181
{"type":"O","frame":6,"at":1274},
1182+
{"type":"O","frame":7,"at":1274},
1183+
{"type":"C","frame":7,"at":1674},
11771184
{"type":"C","frame":6,"at":1674},
1178-
{"type":"C","frame":5,"at":1674},
1179-
{"type":"O","frame":7,"at":1724},
11801185
{"type":"O","frame":8,"at":1724},
1186+
{"type":"O","frame":9,"at":1724},
1187+
{"type":"C","frame":9,"at":1824},
11811188
{"type":"C","frame":8,"at":1824},
1182-
{"type":"C","frame":7,"at":1824},
1183-
{"type":"C","frame":1,"at":1824},
1184-
{"type":"O","frame":9,"at":1866},
1189+
{"type":"C","frame":2,"at":1824},
11851190
{"type":"O","frame":10,"at":1866},
11861191
{"type":"O","frame":11,"at":1866},
1192+
{"type":"O","frame":12,"at":1866},
1193+
{"type":"C","frame":12,"at":2266},
11871194
{"type":"C","frame":11,"at":2266},
11881195
{"type":"C","frame":10,"at":2266},
1189-
{"type":"C","frame":9,"at":2266},
1190-
{"type":"O","frame":12,"at":2316},
11911196
{"type":"O","frame":13,"at":2316},
11921197
{"type":"O","frame":14,"at":2316},
1198+
{"type":"O","frame":15,"at":2316},
1199+
{"type":"C","frame":15,"at":2716},
11931200
{"type":"C","frame":14,"at":2716},
11941201
{"type":"C","frame":13,"at":2716},
1195-
{"type":"C","frame":12,"at":2716},
1196-
{"type":"C","frame":0,"at":2716},
1197-
{"type":"O","frame":15,"at":2758},
1202+
{"type":"C","frame":1,"at":2716},
11981203
{"type":"O","frame":16,"at":2758},
11991204
{"type":"O","frame":17,"at":2758},
12001205
{"type":"O","frame":18,"at":2758},
1206+
{"type":"O","frame":19,"at":2758},
1207+
{"type":"C","frame":19,"at":3158},
12011208
{"type":"C","frame":18,"at":3158},
12021209
{"type":"C","frame":17,"at":3158},
12031210
{"type":"C","frame":16,"at":3158},
1204-
{"type":"C","frame":15,"at":3158},
1205-
{"type":"O","frame":19,"at":3208},
12061211
{"type":"O","frame":20,"at":3208},
12071212
{"type":"O","frame":21,"at":3208},
12081213
{"type":"O","frame":22,"at":3208},
1214+
{"type":"O","frame":23,"at":3208},
1215+
{"type":"C","frame":23,"at":3608},
12091216
{"type":"C","frame":22,"at":3608},
12101217
{"type":"C","frame":21,"at":3608},
12111218
{"type":"C","frame":20,"at":3608},
1212-
{"type":"C","frame":19,"at":3608}
1219+
{"type":"O","frame":24,"at":3650},
1220+
{"type":"C","frame":24,"at":4038},
1221+
{"type":"O","frame":25,"at":4080},
1222+
{"type":"C","frame":25,"at":4204},
1223+
{"type":"O","frame":26,"at":4246},
1224+
{"type":"C","frame":26,"at":4454}
12131225
]
12141226
}
12151227
]

0 commit comments

Comments
 (0)