Skip to content

shrink the size of the type-erasing wrappers#2063

Merged
ericniebler merged 2 commits intoNVIDIA:mainfrom
ericniebler:shrink-type-erasing-wrappers
May 4, 2026
Merged

shrink the size of the type-erasing wrappers#2063
ericniebler merged 2 commits intoNVIDIA:mainfrom
ericniebler:shrink-type-erasing-wrappers

Conversation

@ericniebler
Copy link
Copy Markdown
Collaborator

__any-based type-erasing wrappers are wasting space by over-aligning the internal buffer by default. this PR changes the default buffer alignment from alignof(std::max_align_t) to alignof(void*). this eliminates two pointers worth of padding in the representation of __any<ifooable>.

@ericniebler ericniebler force-pushed the shrink-type-erasing-wrappers branch from 66efd4e to d966791 Compare May 4, 2026 18:24
class _BaseInterfaces = __extends<>,
size_t _BufferSize = __default_buffer_size,
size_t _BufferAlignment = alignof(std::max_align_t)>
size_t _BufferAlignment = alignof(void *)>
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.

Would it be worth adding a small test that checks the sizeof ?

@ericniebler ericniebler merged commit 793da16 into NVIDIA:main May 4, 2026
59 of 60 checks passed
@ericniebler ericniebler deleted the shrink-type-erasing-wrappers branch May 4, 2026 20:30
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