Skip to content

Make internal buffer aligned#70

Draft
AndersTrier wants to merge 1 commit intomasterfrom
AndersTrier/aligned
Draft

Make internal buffer aligned#70
AndersTrier wants to merge 1 commit intomasterfrom
AndersTrier/aligned

Conversation

@AndersTrier
Copy link
Owner

No description provided.

by using crate aligned-vec
[features]
default = ["std"]
std = ["fixedbitset/std"]
std = ["fixedbitset/std", "aligned-vec/std"]
Copy link
Owner Author

Choose a reason for hiding this comment

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

@nazar-pc
This is the way to do it, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, though I'm wondering if any of the APIs used here actually require/benefit from std at all.

@AndersTrier AndersTrier marked this pull request as draft October 14, 2025 20:04
@AndersTrier
Copy link
Owner Author

Probably a better approach to use the built in #[cfg_attr(repr(align(64)))] struct attribute instead. Ex:
https://rust-lang.github.io/hashbrown/src/crossbeam_utils/cache_padded.rs#94-127

@nazar-pc
Copy link
Contributor

If you can use new type then yes. You can also use this hack to align tuples and other data structures:

#[repr(align(64))]
struct CacheLineAligned;

struct S {
    something: [u8; 64],
    _align: CacheLineAligned,
}

This way even though the field is not used, its presence forces alignment of the whole struct. Depends on what you want exactly. aligned-vec is certainly unnecessary and even undesirable for fixed-size data structures.

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