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

Expansion of the TStreamerInfo actions. #16995

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

Conversation

pcanal
Copy link
Member

@pcanal pcanal commented Nov 20, 2024

This add TStreamerInfo actions for the case of base class, nested objects, externally assignment streamer and array thereof (kBase, kAny, kStreamer, kStreamLoop) for both scalar and collection cases. It also expands the scope of the writing actions to cover the collections cases and the new cases (kBase, kAny, kStreamer, kStreamLoop)

Companion PR of root-project/roottest#1224

When executing the streaming on an object, the execution of the case covered by the case kBase, kAny, kStreamer, kStreamLoop was migrated from using the legacy code within the source file TStreamerInfoReadBuffer.cxx and TStreamerInfoWriteBuffer.cxx which is based on a pair of 'giant' switch statement to the newer framework based on the composition of TStreamerInfoActions (and the corresponding collection: TActionSequence). The change from switch statement to a set of function pointers allows to improve performance by executing for each data members only the code strictly necessary.

In its previous implementation (which is still used in a few rare cases involved backward compatibility), the case kBase (for both reading and writing) was forcing the use of the switch statement for all the data members of the base classes. This prevented the use of the new convert-on-write actions (with no existing corresponding implementation in the write switch statement) that are necessary for supporting the Enums with non default size.

This enables the StreamerInfoActions to enable the shortcuts that
are possible in that case.
The version recorded 'here' is the version of the TStreamerInfo class not the user class
Even without schema evolution, the representation of a collection of enums
on file is a `vector<int>` so `TStreamerElement::fType` and `TStreamerElement::fClassObject`
should point to `vector<int>` while `TStreamerElement::fNewType` and
`TStreamerElement::fNewClass` should point to the current in memory representaition
`actualCollectionType< actualEnum >` that will know/remember what is the actual enum
in memory representation.
Combine the code with the one use for the text actions
Combine the code with the one use for the text actions
To use be for case where the read and write implementation differs only slightly
To be used for function template that can be used for more than one actual looper (usually in
conjunction with the LoopOverCollection template
Allow to share code with the collection loopers.
@pcanal pcanal self-assigned this Nov 20, 2024
Copy link

github-actions bot commented Nov 20, 2024

Test Results

    18 files      18 suites   3d 21h 3m 41s ⏱️
 2 687 tests  2 686 ✅ 0 💤 1 ❌
46 530 runs  46 529 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 17097bc.

♻️ This comment has been updated with latest results.

@pcanal pcanal marked this pull request as ready for review November 22, 2024 04:04
@pcanal pcanal requested a review from dpiparo as a code owner November 22, 2024 04:04
@pcanal pcanal requested a review from jblomer November 22, 2024 04:04
@pcanal pcanal closed this Nov 26, 2024
@pcanal pcanal reopened this Nov 26, 2024
Copy link
Member

@dpiparo dpiparo left a comment

Choose a reason for hiding this comment

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

Thanks for this major improvement. I added some comments for the review. In general I believe it could be very useful to take this opportunity, perhaps to the documentation of TStreamerInfo, to add a 1 page explanation of what this major overhaul does, also explaining simply, without code and only in English, what the pre-existing code was doing.

core/meta/inc/TClass.h Show resolved Hide resolved
core/meta/src/TStreamerElement.cxx Show resolved Hide resolved
core/meta/src/TStreamerElement.cxx Show resolved Hide resolved
core/meta/src/TStreamerElement.cxx Show resolved Hide resolved
@@ -188,6 +194,59 @@ namespace TStreamerInfoActions

};

struct TConfObject : public TConfiguration
Copy link
Member

Choose a reason for hiding this comment

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

Maybe could some comment here be useful to clarify why this new struct exists and how it will be used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Humm .. this is one of 'many' specialization of the action configuration object. However we might indeed be missing an overview document of the Sequence/Action/Configuration scaffolding.

return 0;
}
class TConfNoFactor : public TConfiguration {
// Configuration object for the Float16/Double32 where a factor has been specified.
Copy link
Member

Choose a reason for hiding this comment

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

Could a more complete explanation help here, e.g. about what a factor is perhaps with an example?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not quite the right place (and/or would lead to duplicate information). The full explanation is at

////////////////////////////////////////////////////////////////////////////////

As other place, maybe we should refer to TBufferFile::WriteFloat16

@pcanal pcanal changed the title Expansion of the TStreamerInfo actions rules Expansion of the TStreamerInfo actions. Nov 26, 2024
@pcanal
Copy link
Member Author

pcanal commented Nov 26, 2024

to add a 1 page explanation of what this major overhaul does, also explaining simply, without code and only in English, what the pre-existing code was doing.

When executing the streaming on an object, the execution of the case covered by the case kBase, kAny, kStreamer, kStreamLoop was migrated from using the legacy code within the source file TStreamerInfoReadBuffer.cxx and TStreamerInfoWriteBuffer.cxx which is based on a pair of 'giant' switch statement to the newer framework based on the composition of TStreamerInfoActions (and the corresponding collection: TActionSequence). The change from switch statement to a set of function pointers allows to improve performance by executing for each data members only the code strictly necessary.

In its previous implementation (which is still used in a few rare cases involved backward compatibility), the case kBase (for both reading and writing) was forcing the use of the switch statement for all the data members of the base classes. This prevented the use of the new convert-on-write actions (with no existing corresponding implementation in the write switch statement) that are necessary for supporting the Enums with non default size.

core/meta/src/TStreamerElement.cxx Show resolved Hide resolved
core/meta/src/TStreamerElement.cxx Show resolved Hide resolved
io/io/src/TStreamerInfoReadBuffer.cxx Show resolved Hide resolved
io/io/src/TStreamerInfoActions.cxx Show resolved Hide resolved
io/io/src/TStreamerInfoActions.cxx Outdated Show resolved Hide resolved
io/io/src/TStreamerInfoActions.cxx Outdated Show resolved Hide resolved
@@ -1760,9 +1760,7 @@ namespace TStreamerInfoActions
// Read the class version and byte count from the buffer.
UInt_t start = 0;
UInt_t count = 0;
buf.ReadVersion(&start, &count, cl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the commit message be extended explaining in which case the error is triggered?

Copy link
Member Author

@pcanal pcanal Nov 27, 2024

Choose a reason for hiding this comment

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

No error message was actually observed or is expected. The code is clearly asymmetrical between was is written and was is being read. The theorized error message is something like Can not find version 1 of class <wrong class name> and then moving along correctly (beside printing the error) when reading a file produced by the version with version 1 of TStreamerInfo, i.e. version v2.26 (Circa 2001)

io/io/src/TStreamerInfoActions.cxx Show resolved Hide resolved
io/io/src/TStreamerInfoActions.cxx Show resolved Hide resolved
io/io/src/TStreamerInfoReadBuffer.cxx Show resolved Hide resolved
@pcanal pcanal closed this Nov 27, 2024
@pcanal pcanal reopened this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants