Skip to content

Minimum alignment #241

Open
Open
@CeleritasCelery

Description

@CeleritasCelery

I was reading your blog post while looking through the code and noticed that it did not utilize the "minimum alignment trick" mentioned at the end. I wanted to see how much difference it made. I implemented it and run the benchmarks but didn't see any difference in the "small" and "big" ones. The small one obviously won't benefit from alignment and the big benchmark is dominated by the overhead of copying. However I created a medium benchmark with word sized values.

#[derive(Default)]
struct Medium(usize);

In this benchmark I saw 12% throughput improvement when using minimum alignment. There is a similar improvement for allocations up to 8 words in size (much larger than that and the copying overhead starts to dominate the benchmark).

This seems like a sizable improvement. But I also understand that maybe not everyone wants to waste the extra memory if they are doing small or odd-sized allocations. Would you be open to adding this as an optional feature? Updating the code is fairly easy, but the harder part would be updating the tests, since many of them (like quickcheck) hardcode the assumption that there is no min alignment. Let me know what you think. I would submit the PR if this was something you were interested in.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions