Skip to content

Investigate packing and alignment for internal/opaque structs #4510

Open
@jmayclin

Description

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.

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions