Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate packing and alignment for internal/opaque structs #4510

Open
jmayclin opened this issue Apr 18, 2024 · 0 comments
Open

Investigate packing and alignment for internal/opaque structs #4510

jmayclin opened this issue Apr 18, 2024 · 0 comments

Comments

@jmayclin
Copy link
Contributor

jmayclin commented Apr 18, 2024

Problem:

When running clang-tidy with the altera-struct-pack-align there are a number of warnings about alignment and packing that are printed out. We should investigate the performance impact and memory impacts of following these recommendations.

Example output

/home/ec2-user/workspace/s2n-tls/utils/s2n_random.c:99:8: warning: accessing fields in struct 's2n_rand_state' is inefficient due to padding; only needs 89 bytes but is using 96 bytes [altera-struct-pack-align]
struct s2n_rand_state {
       ^
/home/ec2-user/workspace/s2n-tls/utils/s2n_random.c:99:8: note: use "__attribute__((packed))" to reduce the amount of padding applied to struct 's2n_rand_state'
/home/ec2-user/workspace/s2n-tls/utils/s2n_random.c:99:8: warning: accessing fields in struct 's2n_rand_state' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 128 bytes [altera-struct-pack-align]
struct s2n_rand_state {

Solution:

I'm not totally certain of the interaction between packed and alignment. More investigation is needed.

@jmayclin jmayclin changed the title Consider using __attribute__((packed)) for opaque and internal structs Investigate packing and alignment for internal/opaque structs Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants