Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ntuple] Mark RField methods as final and remove duplicate implementations #16721

Merged
merged 10 commits into from
Oct 22, 2024

Conversation

hahnjo
Copy link
Member

@hahnjo hahnjo commented Oct 20, 2024

  • Mark (most) RField specializations as final; the only exception is RField<std::array<ItemT, N>> which is the base class of RField<ItemT[N]>.
  • Mark (most) overriden functions in the RFieldBase hierarchy as final; the only exception is RSimpleField::GenerateColumns which is overriden by RRealField.
  • Remove many duplicate implementations in the compile-time specialized classes: The reasoning is that we use the type-erased implementations with RFieldBase::Create, when reconstructing a model from disk, or when Cloneing a model. So if they are not performant, we have to fix them anyway. For completeness, there seems to be no performance change in the iotools benchmarks (with hot cache, to put emphasis on the RNTuple implementation).

hahnjo added 10 commits October 20, 2024 12:13
This doesn't make a difference because the classes are already final,
but simplifies automated checking.
They should be leaves in the class hierarchy.
It is provided by the type-erased RRVecField. On model reconstruction
and via RFieldBase::Create, we use this implementation anyway and it
actually contains optimizations to use AppendV and ReadV, if possible.
The implementations were identical to the generic ones in
RProxiedCollectionField.
This pessimizes the alignment of RMapField and RSetField to that of
std::max_align_t, but they were wrong anyway because they assumed that
all std::[unordered_][multi]map and all std::[unordered_][multi]set
have the same alignment.
They are provided by the type-erased base classes.
It was only used in the constructor, and also not properly taken care
of by CloneImpl().
@hahnjo hahnjo self-assigned this Oct 20, 2024
Copy link

Test Results

    17 files      17 suites   3d 19h 37m 6s ⏱️
 2 714 tests  2 712 ✅ 0 💤 2 ❌
43 528 runs  43 526 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit 5e6d5a5c.

Copy link
Contributor

@jblomer jblomer left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

new (where) T();
} else {
// If there is no default constructor, try with the IO constructor
new (where) T(static_cast<TRootIOCtor *>(nullptr));
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the tests still work, I assume TClass::New() takes proper care of using the I/O constructor where applicable...?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, in fact now I learned that TClass::New() allows more customization from the user: https://root.cern.ch/doc/master/classTClass.html#a1e952a88f08eb6ec665a7ac862860689. I cross-checked that removing the IO constructor of class IOConstructor in tree/ntuple/v7/test/CustomStruct.hxx fails the ntuple-types test, so it seems to be working with this PR.

Copy link
Member

@pcanal pcanal Oct 22, 2024

Choose a reason for hiding this comment

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

Yes, this is essentially the whole point of TClass::New: construct the object during I/O operations :)
(and usually it does not require any run-time compilation/interpretation as the dictionary provide an accelerator function wrapping the 'right' call to operator new + constructor.

@hahnjo hahnjo merged commit 91d697a into root-project:master Oct 22, 2024
20 of 21 checks passed
@hahnjo hahnjo deleted the ntuple-field-final branch October 22, 2024 06:50
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.

3 participants