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

Add Global deallocation variant (#3516) #3517

Closed
wants to merge 2 commits into from

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Part of #3516

Rationale for this change

This is the first part of supporting zero-copy conversion between Vec and MutableBuffer. Crucially we need to carry along the Layout as it is UB to call realloc or dealloc with a different layout from the one provided to the initial call to alloc.

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jan 12, 2023
@@ -135,20 +135,25 @@ pub(crate) enum Deallocation {
/// An allocation of the given capacity that needs to be deallocated using arrows's cache aligned allocator.
/// See [allocate_aligned] and [free_aligned].
Arrow(usize),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually I could see us removing this in favor of Global, but I kept it for now

/// An allocation from an external source like the FFI interface or a Rust Vec.
/// Deallocation will happen
/// An allocation using the system's default global allocator and the provided layout
Global(Layout),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does increase the size of Dellocation by 8 bytes. In practice this is extremely unlikely to matter

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

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

Not sure how this is going to be used. But the addition looks reasonable by itself.

@tustvold tustvold marked this pull request as draft January 13, 2023 07:54
@tustvold
Copy link
Contributor Author

I need to think a bit more on this, the challenge is Vec will call dealloc with the alignment it would ask for, not the alignment that is actually correct 🤔

@tustvold
Copy link
Contributor Author

I plan to handle this differently

@tustvold tustvold closed this Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants