Skip to content

Conversation

@jblomer
Copy link
Contributor

@jblomer jblomer commented Oct 9, 2024

Version leading into the 1.0 format. Final cleanups and removal of backward compatibility code for previous experimental anchors.

@jblomer jblomer self-assigned this Oct 9, 2024
@jblomer jblomer marked this pull request as draft October 9, 2024 13:07
@github-actions
Copy link

github-actions bot commented Oct 9, 2024

Test Results

    18 files      18 suites   3d 18h 36m 23s ⏱️
 2 699 tests  2 697 ✅ 1 💤 1 ❌
46 129 runs  46 128 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 2a90c5f.

♻️ This comment has been updated with latest results.

Copy link
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two quick questions regarding RNTuple::Streamer()

auto classVersion = buf.ReadVersion(&offClassBuf, &bcnt);
if (classVersion < 4)
throw RException(R__FAIL("unsupported RNTuple pre-release"));
buf.ReadVersion(&offClassBuf, &bcnt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? My understanding is that it was required for the custom streaming of class version 4. I didn't check how this interferes with the checksum below, but I believe that offCkData takes care of skipping the class version already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related question, how does the reading fail after the PR when reading old (unsupported) RNtuple files?

Copy link
Contributor Author

@jblomer jblomer Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails to open à la "ROOT::Experimental::RNTuple is not an RNTuple". It's like trying to open an RNTuple from a TTree or and TH1F key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? My understanding is that it was required for the custom streaming of class version 4. I didn't check how this interferes with the checksum below, but I believe that offCkData takes care of skipping the class version already.

I thought we need this to get the byte count (bcnt).. @silverweed ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... I believe we can reverse the operations: first read the "final" ReadClassBuffer, then compute the checksum and compare it to the value on disk.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I had in mind: hahnjo@3649c92 (feel free to just pick into this PR, or we can do it as follow-up) It compares the checksum only after reading the class, but this is likely fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now submitted as #16956

Comment on lines 46 to 47
// Rewind the version bytes, as ReadClassBuffer needs to read the version again.
buf.SetBufferOffset(offClassBuf);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above; maybe we can remove this?

@jblomer jblomer force-pushed the ntuple-rc3 branch 3 times, most recently from 5b2f516 to 23e17c9 Compare October 10, 2024 14:27
Comment on lines 47 to 48
buf.SetBufferOffset(offClassBuf);
buf.ReadClassBuffer(RNTuple::Class(), this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this the first time around, we should be using:

   virtual   Int_t    ReadClassBuffer(const TClass *cl, void *pointer, Int_t version, UInt_t start, UInt_t count, const TClass *onfile_class = nullptr) = 0;
Suggested change
buf.SetBufferOffset(offClassBuf);
buf.ReadClassBuffer(RNTuple::Class(), this);
buf.ReadClassBuffer(RNTuple::Class(), this, classVersion, bcnt);

rather than do the version reading twice.

@jblomer jblomer marked this pull request as ready for review October 11, 2024 08:33
@jblomer jblomer requested a review from couet as a code owner October 11, 2024 08:33
@jblomer jblomer marked this pull request as draft October 11, 2024 09:05
@jblomer jblomer marked this pull request as ready for review October 11, 2024 09:42
@jblomer jblomer requested review from hahnjo and pcanal October 11, 2024 12:21
@jblomer jblomer marked this pull request as draft October 11, 2024 14:39
@jblomer
Copy link
Contributor Author

jblomer commented Oct 11, 2024

Draft for now. We don't want to merge it before CHEP in order to not impact benchmarks done on master.

@jblomer jblomer force-pushed the ntuple-rc3 branch 2 times, most recently from 43cefee to 3397df9 Compare October 31, 2024 08:42
Make the on-disk type name of the cardinality field spell
`ROOT::RNTupleCardinality<T>` instead of
`ROOT::Experimental::RNTupleCardinality<T>`.
@jblomer jblomer marked this pull request as ready for review October 31, 2024 13:15
namespace Experimental {
class RNTuple;

namespace Experimental {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are those still in Experimental? Should they be in Internal and/or Detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, at this point only type names that are part of the on-disk format move out of experimental.

#include <vector>

using namespace ROOT::Experimental;
using namespace ROOT::Experimental::Internal;
Copy link
Member

@pcanal pcanal Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using namespace ROOT::Experimental::Internal;
using namespace ROOT;
using namespace ROOT::Experimental::Internal;

(and keeping the rest of the code as it was).
seems to match 'better' the spirit of this file coding style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea of using namespace ROOT::Experimental::Internal was avoiding long boilerplate strings throughout the file. However, I find the ROOT:: prefix short and concise and I'd have a preference of writing ROOT::RNTuple rather than RNTuple (similar to std::string over string).

@jblomer jblomer force-pushed the ntuple-rc3 branch 3 times, most recently from 5289735 to 294f9a6 Compare November 1, 2024 04:11
@jblomer jblomer requested review from hahnjo and pcanal November 1, 2024 04:11
@jblomer
Copy link
Contributor Author

jblomer commented Nov 1, 2024

Note: clang-format is fine with the changes except that it doesn't understand string literals.

Copy link
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@enirolf enirolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small comments, LGTM otherwise!

offset = key.GetSeekKey() + key.fKeyLen;

constexpr size_t kMinNTupleSize = 70; // size of a RTFNTuple version 4 (min supported version)
constexpr size_t kMinNTupleSize = 78; // size of a RTFNTuple version 2 (min supported version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason RTFNuple::GetSizePlusChecksum is not used here instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the idea is that the anchor size can grow in the future, so we have to maintain kMinNTupleSize independently of the RTFNuple structure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that contradicts the comment next to it then, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm not sure, for me it's quite clear:

  • For future versions 3, 4, 5, ... RTFNTuple gains more members that have a default initialization. That will increase RTFNuple::GetSizePlusChecksum
  • This exact line will forever stay like this because it was the size of RTFNTuple version 2, when we declared RNTuple 1.0.0.0, and we will always be able to read it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll left the hard-coded 78 but added a static_assert, which makes it clear that this number is currently identical to RTFNuple::GetSizePlusChecksum(). If we grow the anchor in the future, the static assert will remind us of this spot.

Moves ROOT::Experimental::RNTuple to ROOT::RNTuple. Resets class version
to 2 (general first class version recommendation for new classes).
Removes previous compatibility code.
For historical reasons, the current column flags are 0x08 and 0x10.
Reset to 0x01 and 0x02 for format RC3.
Make sure that we can easily extend the field meta-data by putting all
the mandatory components first and the optional components last.
There is no (foreseen) use of a version range for the extra type info.
Its only current purpose, storing streamer info records, does not need
the version at all. A possible future use is storing enum constant names,
but that would also be bound to a specific type version and not to a
version range.

If needed in a future version, a type version range can be added then.
@jblomer jblomer merged commit d2a8b3c into root-project:master Nov 4, 2024
18 of 21 checks passed
@jblomer jblomer deleted the ntuple-rc3 branch November 4, 2024 14:00
constexpr size_t kMinNTupleSize = 70; // size of a RTFNTuple version 4 (min supported version)
// size of a RTFNTuple version 2 (min supported version); future anchor versions can grow.
constexpr size_t kMinNTupleSize = 78;
static_assert(kMinNTupleSize == RTFNTuple::GetSizePlusChecksum());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< static_assert(kMinNTupleSize == RTFNTuple::GetSizePlusChecksum());

static_assert(kMinNTupleSize <= RTFNTuple::GetSizePlusChecksum());

| 0x08 | 32 | Real32 | IEEE-754 single precision float |
| 0x09 | 16 | Real16 | IEEE-754 half precision float |
| 0x16 | 64 | Int64 | Two's complement, little-endian 8-byte signed integer |
| 0x00 | 1 | Bit | Boolean value |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this start at 0x00 instead of 0x01 now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was part of the format cleanup. It seemed unclear why we should not not start at 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants