Skip to content

[ntuple] improve type name renormalization #19323

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jblomer
Copy link
Contributor

@jblomer jblomer commented Jul 9, 2025

Add different code path for renormalizing a demangled typeid name. Such type names come from RField<T>::TypeName(). In this case, the compiler has done already most of the normalization work and we don't need to go through ROOT meta. More importantly, the result does not depend on the state of ROOT Meta, e.g. the set of loaded libraries.

There are some parts ROOT meta does that we need to repeat for this case, e.g. dropping optional template arguments of stdlib containers.

Secondly, this PR clarifies and fixes normalization of C style fixed-size arrays.

Together, this makes the new patch version 1.0.0.2 of the spec and the anchor.

This PR fixes #19116

@jblomer jblomer requested review from hahnjo and vepadulano July 9, 2025 20:50
@jblomer jblomer self-assigned this Jul 9, 2025
@jblomer jblomer force-pushed the ntuple-type-normalization branch from e3747e0 to 3153961 Compare July 9, 2025 20:53
@jblomer jblomer requested review from pcanal, silverweed and enirolf July 9, 2025 21:20
Copy link

github-actions bot commented Jul 9, 2025

Test Results

    21 files      21 suites   3d 10h 5m 26s ⏱️
 3 211 tests  3 211 ✅ 0 💤 0 ❌
65 708 runs  65 708 ✅ 0 💤 0 ❌

Results for commit 17d162f.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@silverweed silverweed left a comment

Choose a reason for hiding this comment

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

Small comment + a warning from the compiler

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.

The approach looks good to me. We need to add handling of the __1 inline namespace of libc++, and find a solution for the ATLAS DataVector with suppressed template arguments.

@ferdymercury
Copy link
Collaborator

Maybe related: https://its.cern.ch/jira/browse/ROOT-5862

@jblomer jblomer force-pushed the ntuple-type-normalization branch from 3153961 to b4d5353 Compare July 14, 2025 09:25
@jblomer jblomer requested a review from dpiparo as a code owner July 14, 2025 09:25
@jblomer jblomer force-pushed the ntuple-type-normalization branch 5 times, most recently from 26d39e5 to 147b9e0 Compare July 15, 2025 19:23
@jblomer jblomer force-pushed the ntuple-type-normalization branch 2 times, most recently from dc663fe to 17d162f Compare July 16, 2025 11:50
Comment on lines -24 to -25
const std::string expectedAfter{"AtlasLikeDataVector<CustomStruct>"};
// Make sure autoloading happened and the rule to suppress the second template argument kicked in
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that removing the test of the actual ATLAS issue?

Copy link
Member

Choose a reason for hiding this comment

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

I.e. don't we need both the original testing and a new test?

Copy link
Contributor Author

@jblomer jblomer Jul 16, 2025

Choose a reason for hiding this comment

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

The problem observed by ATLAS is tested above. This particular part tests the TypeName() function only, which in the DataVector case is different from RField<T>::GetTypeName(). What we test now (after the patch) is that TypeName() always gives the same result independent of the currently loaded libraries.

It's arguably weak for that purpose and we may drop the TypeName() part here altogether.

Copy link
Member

Choose a reason for hiding this comment

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

I am missing something as I dont see anymore the test for the short name being there ... I am especially thrown off by the comment that is being removed:

Make sure autoloading happened and the rule to suppress the second template argument kicked in

which seems explicitly say that the above call and follow test are exactly for the ATLAS scenario ... and/or where should that comment move to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 21 is the actual test:

ASSERT_NO_THROW(entry.GetPtr<AtlasLikeDataVector<CustomStruct>>("my_field"));

We ask for a shared pointer without the extra template argument, and it works even tough on disk the extra argument is present.

Copy link
Member

@pcanal pcanal Jul 16, 2025

Choose a reason for hiding this comment

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

I am quite confused. If/since new line 24 set the expectation to recording with the long name, then line 21 will work with or without the dictionary (demangled name match the long name).

So unless we also make sure that in the test the 'current' long name does not match the long name when storing the file (I can't recall if we are doing that), then we wouldn't really test the feature ('please ignore the 2nd argument') ... (that is, unless I am still missing something)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, you're right! The test didn't make much sense. I added a modified version which I hope makes more sense.

Copy link
Member

Choose a reason for hiding this comment

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

At which point in the new test is the autoloading of the library triggered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I'm not sure. I guess by the constructor of ROOT::RField<AtlasLikeDataVector<CustomStruct>>? But does it matter?

Copy link
Member

Choose a reason for hiding this comment

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

It does in the sense that the previous code/test was checking both before and after the autoloading, ensuring that the autoloading did happen. Without these tests, the test can later be unwittingly updated to no longer test the autoloading at all (for example by explicitly linking the dictionary library) and thus removing the test of 'RNTuple use of a specific time customized by the users will ensure that the user's library is auto-loaded' (and thus increasing the possibility that we unwittingly stop supporting it)

@jblomer jblomer force-pushed the ntuple-type-normalization branch 2 times, most recently from 0b8f607 to f3b60e0 Compare July 16, 2025 20:17
@jblomer jblomer requested review from hahnjo and silverweed July 16, 2025 20:22
Add clarifications on type name normalization wrt.
- type name resolution of stdlib types
- treatment of C style fixed-size arrays.
- CV qualifier treatment in template arguments

These points follow implicitly from the specification of the supported
C++ types but it is useful to add them explicitly to the type name
normalization rules. Since in the process also bugs were discovered
related to fixed-size arrays, we give this specification a bump in the
patch version number.
@jblomer jblomer force-pushed the ntuple-type-normalization branch 2 times, most recently from 3b407ac to 0648fc5 Compare July 17, 2025 16:01
jblomer added 5 commits July 17, 2025 18:01
Add different code path for renormalizing a demangled typeid name. Such
type names come from RField<T>::TypeName(). In this case, the compiler
has done already most of the normalization work and we don't need to go
through ROOT meta. There are some parts ROOT meta does that we need to
repeat for this case, e.g. dropping optional template arguments of
stdlib containers.
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.

Re-evaluate the implementation of RField<T>::TypeName
5 participants