-
Notifications
You must be signed in to change notification settings - Fork 112
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
alloc_layout_slow and guarantees for iter_allocated_chunks #46
Comments
If I am understanding correctly, the issue is:
Correct? It seems to me we can continue to support arbitrary alignments with minimal changes by adding a field to the chunk footer that is the end of the first allocation in a chunk. If there wasn't any padding inserted due to rounding down allocation, then this will point at the chunk footer itself, otherwise it will point at the start of the padding we added. When we create slices to give out in What do you think of this plan? |
Yes, your understanding mirrors mine. I think your plan is a good one. |
Would you be willing to implement this? |
I have implemented two alternative fixes for this issue. I personally believe #48 to be the better one. It should be faster and waste less memory. The downside of it is that we will no longer support |
Fixes for #46 by always aligning the requested memory to 16 bytes
Fixed in #48 |
I agree that the fix made in #45 is the right one, however it has a problem: It can introduce padding bytes in the output of
iter_allocated_chunks
for large alignments.I think it is fine to introduce padding for large alignments, but we need to decide where to draw the line between support and not supported -- and we need to improve the documentation to reflect this.
I do not have any strong opinions on how large an alignment we should support. I guess it would be nice to support up to alignment 16, since that is largest alignment of that real world code can sometimes need.
However I do not think that anybody who has 16-byte alignment requirements would also want to use
iter_allocated_chunks
.Here is some code I used to test this:
The text was updated successfully, but these errors were encountered: