Skip to content

io: Support 64 bits position/byte-count #20574

Draft
pcanal wants to merge 20 commits intoroot-project:Arlesiennefrom
pcanal:Arlesienne
Draft

io: Support 64 bits position/byte-count #20574
pcanal wants to merge 20 commits intoroot-project:Arlesiennefrom
pcanal:Arlesienne

Conversation

@pcanal
Copy link
Member

@pcanal pcanal commented Nov 29, 2025

No description provided.

@pcanal pcanal self-assigned this Nov 29, 2025
@github-actions
Copy link

github-actions bot commented Nov 29, 2025

Test Results

    1 files      1 suites   6h 57m 18s ⏱️
3 386 tests 3 285 ✅ 101 💤 0 ❌
3 386 runs  3 386 ✅   0 💤 0 ❌

Results for commit 4248799.

♻️ This comment has been updated with latest results.

Fixes root-project#14770

[io] add more checks in TBuffer functions

as suggested by jblomer
@pcanal pcanal reopened this Dec 2, 2025
@pcanal pcanal force-pushed the Arlesienne branch 2 times, most recently from 00fe0ac to 41a877a Compare December 4, 2025 01:29
In order to support 64 bits byte count, which does not fit in the space reverse for them
in the stream (4 bytes minus 3 control bits) and the position and some byte count do not
fit in the variable used in existing code (arguments to WriteVersion, SetByteCount,
ReadVersion and CheckByteCount), we need to pass them indirectly.

Since the streaming is inherently serial, we can leverage the
sequence of calls and cache the 64 bits values in a queue.

The bytecount that can not be stored in place in the stream will be held
in a collection (fByteCounts) that need to be stored externally to the
buffer.
Note to store and restore the larger than 1GB byte count use:

  // Copy the content of the const reference.
  auto bytecounts{b.GetByteCounts()};
  ...
  b.SetByteCounts(std::move(bytecounts));
@pcanal pcanal requested review from bellenot, jblomer and silverweed and removed request for bellenot December 8, 2025 23:02
@pcanal pcanal marked this pull request as ready for review December 8, 2025 23:03
@pcanal pcanal requested a review from bellenot as a code owner December 8, 2025 23:03
@pcanal pcanal removed the request for review from bellenot December 9, 2025 15:28
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.

I have difficulties parsing the first sentence of the commit message of the first commit. Also, this sentence mentions three control bits. Isn't it just two (up to kByteCountMask, i.e. 0x40000000)?

We may want to swap the reading and writing commits so that the code always works correctly on small objects.

////////////////////////////////////////////////////////////////////////////////
/// Read class version from I/O buffer.

Version_t TBufferFile::ReadVersion(UInt_t *startpos, UInt_t *bcnt, const TClass *cl)
Copy link
Contributor

Choose a reason for hiding this comment

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

If both startpos and bcnt are provided, the code may add the position to fByteCountStack (it doesn't if the serialized object doesn't have a byte count). That means that the caller of ReadVersion needs to pop from the stack, correct? This looks a bit brittle and should at least be documented.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the user does not provide the address of their bytecount variable, they will not be given the value of the byte count and thus they can not and will not call CheckByteCount.
If the user has provided the address, we assume they are using it in a call to CheckByteCount.
I will add to the doc string that the CheckByteCount call is (now) required.

@pcanal
Copy link
Member Author

pcanal commented Feb 5, 2026

We may want to swap the reading and writing commits so that the code always works correctly on small objects.

Currently the reading commit is first and should be able to read small buffers ... or am I missing something?

@pcanal
Copy link
Member Author

pcanal commented Feb 5, 2026

I have difficulties parsing the first sentence of the commit message of the first commit.

New wording:

io: Add data structure for 64 bit byte count.
    
In order to support 64 bits byte counts, which do not fit in the space reserved
for them in the stream (4 bytes minus 2 control bits) and to work around the
fact that the variables that holds the position and the byte count information in
Streamer functions are only 32 bits (see arguments to TBufferFile::WriteVersion
and TBufferFile::ReadVersion), we need to pass them indirectly when they needs 64 bits

Since the streaming is inherently serial, we can leverage the
sequence of calls and cache the 64 bits values in a queue.

The bytecount that can not be stored in place inside the io stream will be held
in a collection (fByteCounts) that need to be stored externally to the
buffer.

Also, this sentence mentions three control bits. Isn't it just two (up to kByteCountMask, i.e. 0x40000000)?

Correct.

@pcanal
Copy link
Member Author

pcanal commented Feb 6, 2026

@jakob This PR is kept open but put on Draft mode to keep the conversation going. However because of the branch naming limitation, I have to move the testing (and merging) to a new PR: #21183 which has a cleaned up (final?) list of commits.

@pcanal pcanal marked this pull request as draft February 6, 2026 20:47
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.

4 participants