Skip to content

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

Open
pcanal wants to merge 12 commits intoroot-project:Arlesiennefrom
pcanal:Arlesienne_ByteCount
Open

io: Support 64 bits position/byte-count#21183
pcanal wants to merge 12 commits intoroot-project:Arlesiennefrom
pcanal:Arlesienne_ByteCount

Conversation

@pcanal
Copy link
Member

@pcanal pcanal commented Feb 6, 2026

Continuation/Replacement of #20574 with a new incoming branch name to enable proper testing.

pcanal added 12 commits February 6, 2026 21:45
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 a review from jblomer February 6, 2026 20:46
@pcanal pcanal self-assigned this Feb 6, 2026
@pcanal pcanal requested a review from bellenot as a code owner February 6, 2026 20:46
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Test Results

    22 files      22 suites   3d 8h 35m 32s ⏱️
 3 777 tests  3 728 ✅   1 💤  48 ❌
75 140 runs  73 981 ✅ 253 💤 906 ❌

For more details on these failures, see this check.

Results for commit a74d03a.

@jblomer
Copy link
Contributor

jblomer commented Feb 7, 2026

The first commit message didn't get reworded, I think. Cf. #20574 (comment)

auto full_cntpos = fBufCur - fBuffer;
fByteCountStack.push_back(full_cntpos);
*this << (UInt_t)kByteCountMask; // placeholder for byte count
return full_cntpos < kMaxCountPosition ? full_cntpos : kOverflowPosition;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return full_cntpos < kMaxCountPosition ? full_cntpos : kOverflowPosition;
return full_cntpos <= kMaxCountPosition ? full_cntpos : kOverflowPosition;


////////////////////////////////////////////////////////////////////////////////
/// Read class version from I/O buffer.
/// If passing startpos and bcnt, CheckByteCount must be called later with
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it valid to set only one of them? If not, we can assert both are set or both are nullptr and simplify a bit the logic.

// support storing more than 1GB in a single TBufferFile.
const bool bufferLimitedToMaxMapCount = false;
if (bufferLimitedToMaxMapCount && IsWriting()) {
if (offset >= kMaxRecordByteCount) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (offset >= kMaxRecordByteCount) {
if (offset > kMaxRecordByteCount) {

@pcanal pcanal changed the title [io] Properly abort when buffer size overflows max integer io: Support 64 bits position/byte-count Feb 8, 2026
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.

2 participants