Skip to content

[ntuple] Fixes for alignment#22312

Open
jblomer wants to merge 3 commits into
root-project:masterfrom
jblomer:ntuple-update-align
Open

[ntuple] Fixes for alignment#22312
jblomer wants to merge 3 commits into
root-project:masterfrom
jblomer:ntuple-update-align

Conversation

@jblomer
Copy link
Copy Markdown
Contributor

@jblomer jblomer commented May 16, 2026

Use the new TClass alignment information where applicable. This fixes

  • Alignment of classes whose alignment is defined by a transient member
  • Alignment of certain streamer fields

Additionally, use the new and delete operators with alignment info. This ensures correct memory allocation for over-aligned types.

Fixes #16765

@jblomer jblomer self-assigned this May 16, 2026
@jblomer jblomer requested a review from bellenot as a code owner May 16, 2026 05:32
@jblomer jblomer requested review from dpiparo and pcanal as code owners May 16, 2026 05:32
@jblomer jblomer force-pushed the ntuple-update-align branch from bb61c3d to 694bd02 Compare May 16, 2026 07:25
@jblomer jblomer requested review from enirolf, hahnjo and silverweed May 16, 2026 07:26
@jblomer jblomer force-pushed the ntuple-update-align branch from 694bd02 to 27ddc85 Compare May 16, 2026 07:35
@jblomer jblomer force-pushed the ntuple-update-align branch from 27ddc85 to ba94832 Compare May 16, 2026 07:42
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 16, 2026

Test Results

    16 files      16 suites   2d 8h 34m 9s ⏱️
 3 829 tests  3 829 ✅ 0 💤 0 ❌
55 134 runs  55 134 ✅ 0 💤 0 ❌

Results for commit ba94832.

♻️ This comment has been updated with latest results.

@jblomer jblomer added the clean build Ask CI to do non-incremental build on PR label May 16, 2026
@jblomer jblomer closed this May 16, 2026
@jblomer jblomer reopened this May 16, 2026
return (value + align - 1) & ~(align - 1);
}

/// Storage type whose alignment matches \a Align bytes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Storage type whose alignment matches \a Align bytes.
/// Storage type whose alignment matches \a AlignT bytes.

#endif // _MSC_VER
}

inline bool IsPowerOfTwo(std::uint64_t v)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You may (or may not) want to use this in IsValidAlignment (which is only different as it reject 0)


void ROOT::RFieldBase::EnsureValidAlignment(std::size_t alignment)
{
if (alignment == 0 || alignment > ROOT::RFieldBase::kMaxAlignment || !ROOT::Internal::IsPowerOfTwo(alignment))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is similar (but different) to ROOT::Internal::IsValidAlignment.

Suggested change
if (alignment == 0 || alignment > ROOT::RFieldBase::kMaxAlignment || !ROOT::Internal::IsPowerOfTwo(alignment))
if (!ROOT::Internal::IsValidAlignment(alignment) || alignment > ROOT::RFieldBase::kMaxAlignment)

At least in the main I/O part the limitation to 4096 is only for std::vector because they can be handled without dictionary (but then we need to explicitly handle the alignment of their content.

Is RNTuple more restrictive (i.e. calling an generically provided call to new for various alignment?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR in:RNTuple Small Bug Density

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ntuple] Wrong alignment with transient class member

3 participants