Skip to content

feat(allocator): remove drop operations from Vec2 #9679

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

Merged

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Mar 11, 2025

Just like #6623. Since we have control over the Vec implementation, we can remove the drop operations and eventually revert the changes made in #6623 directly.

Copy link
Member Author

Dunqing commented Mar 11, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

codspeed-hq bot commented Mar 11, 2025

CodSpeed Performance Report

Merging #9679 will not alter performance

Comparing 03-11-feat_allocator_remove_drop_operations_from_vec2 (65643bc) with main (d13817e)

Summary

✅ 33 untouched benchmarks

@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from 580a508 to bd3dede Compare March 11, 2025 07:29
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from e7aa3de to c20bc2e Compare March 11, 2025 10:26
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch 2 times, most recently from 9cd5c00 to 408ac4e Compare March 11, 2025 11:49
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from c20bc2e to 5351a48 Compare March 11, 2025 11:49
@Dunqing
Copy link
Member Author

Dunqing commented Mar 11, 2025

I am not sure which drop can be removed, I may need to take a look at Bumpalo's Bump implementation.

@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from 5351a48 to d7ed2b3 Compare March 12, 2025 08:59
@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from 408ac4e to c42ddc7 Compare March 12, 2025 08:59
@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from d7ed2b3 to c0e0d41 Compare March 13, 2025 01:42
@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from c42ddc7 to abeeffb Compare March 13, 2025 01:42
@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from c0e0d41 to cf32c65 Compare March 13, 2025 03:03
@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from abeeffb to 1e132d3 Compare March 13, 2025 03:04
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from 1e132d3 to ea60f86 Compare March 13, 2025 03:51
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from cf32c65 to 0727727 Compare March 13, 2025 03:51
@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch 2 times, most recently from 6545eb1 to 0454799 Compare March 13, 2025 04:04
@overlookmotel overlookmotel force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from ea60f86 to c41251f Compare March 13, 2025 04:04
@overlookmotel
Copy link
Contributor

I am not sure which drop can be removed, I may need to take a look at Bumpalo's Bump implementation.

We can remove loads. But I'd suggest starting by just removing:

  • impl<'bump, T> Drop for Vec<'bump, T>
  • impl<'a, T> Drop for RawVec<'a, T>

That'd bring vec2::Vec up to parity with current Vec. It'd be enough to then be able to remove ManuallyDrop from Vec so Vec becomes just struct Vec(vec2::Vec);.

Removing further Drop-related code would be an improvement over what we have now. I'd be interested to see if it affects benchmarks as we take them out one by one.

But we may want to simplify/remove other code first. bumpalo's implementation offers various options which we don't use, and they clutter the code and make it harder to see what's going on. I suggest we discuss next steps once we've got the first parts merged.

@Dunqing Dunqing force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from 0454799 to 958af20 Compare March 13, 2025 08:03
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from c41251f to eca5456 Compare March 13, 2025 08:03
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from eca5456 to b3558da Compare March 13, 2025 08:15
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 branch from 958af20 to 328e5d0 Compare March 13, 2025 08:15
@Dunqing Dunqing marked this pull request as ready for review March 13, 2025 09:22
Copy link
Contributor

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

Could we limit the scope of this PR to just removing these 2?

  • impl<'bump, T> Drop for Vec<'bump, T>
  • impl<'a, T> Drop for RawVec<'a, T>

Those 2 Drop impls are definitely fine to remove. The other ones are less clear without reading all the code around them.

I think it's preferable to go step-by-step on this. It'd be very easy to make a mistake somewhere and cause UB, so I think it's better to err on the side of caution.

@Dunqing
Copy link
Member Author

Dunqing commented Mar 14, 2025

Could we limit the scope of this PR to just removing these 2?

  • impl<'bump, T> Drop for Vec<'bump, T>
  • impl<'a, T> Drop for RawVec<'a, T>

Those 2 Drop impls are definitely fine to remove. The other ones are less clear without reading all the code around them.

I think it's preferable to go step-by-step on this. It'd be very easy to make a mistake somewhere and cause UB, so I think it's better to err on the side of caution.

This PR is already just removing these 2 which you suggested, additionally, removed mem::forgot because non-drop calling mem::forgot is meaningless.

@graphite-app graphite-app bot changed the base branch from 03-11-feat_allocator_replace_allocator_ap2_s_vec_with_vec2 to graphite-base/9679 March 14, 2025 06:13
@graphite-app graphite-app bot force-pushed the graphite-base/9679 branch from 328e5d0 to 5cc614a Compare March 14, 2025 06:21
@graphite-app graphite-app bot force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from b3558da to a202e87 Compare March 14, 2025 06:21
@graphite-app graphite-app bot changed the base branch from graphite-base/9679 to main March 14, 2025 06:22
@graphite-app graphite-app bot force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from a202e87 to fbba78c Compare March 14, 2025 06:22
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from fbba78c to 32f8347 Compare March 14, 2025 06:24
@overlookmotel
Copy link
Contributor

This PR is already just removing these 2 which you suggested, additionally, removed mem::forgot because non-drop calling mem::forgot is meaningless.

OK. I was being lazy. I didn't want to check what self was referring to in the mem::forget(self) calls that you removed.

I have checked now - self is always a vec2::Vec in these places, so yes you're right the mem::forget calls are pointless.

But could you replace them with comments saying something like this?

// Don't need `mem::forget(self)` here, because `Vec` does not implement `Drop`

@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from 32f8347 to dda7025 Compare March 14, 2025 07:44
@Dunqing
Copy link
Member Author

Dunqing commented Mar 14, 2025

But could you replace them with comments saying something like this?

// Don't need `mem::forget(self)` here, because `Vec` does not implement `Drop`

Done!

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 14, 2025
Copy link
Contributor

overlookmotel commented Mar 14, 2025

Merge activity

  • Mar 14, 3:50 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 14, 3:50 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 14, 3:57 AM EDT: A user merged this pull request with the Graphite merge queue.

Just like #6623. Since we have control over the `Vec` implementation, we can remove the `drop` operations and eventually revert the changes made in #6623 directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants