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

Removes remove_on_drop field from AppendVec #32741

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Aug 7, 2023

Problem

Sometimes we do not want to remove the backing storage file when dropping an AppendVec. This only happens in tests or in store-tool. Instead of keeping a boolean around per instance to decide if we remove the file or not on drop, we can use ManuallyDrop to not remove the file when we want that behavior.

Summary of Changes

  • AppendVec will always remove backing storage file in drop
  • Remove remove_on_drop field from AppendVec
  • Use ManuallyDrop when we do not want to remove the backing storage file

Note, the set_no_remove_on_drop() method is not removed in this PR, just turned into a no-op. There are zero callers of this function, so should be safe. The next PR will remove this method, and I'm not worried about a rogue PR getting merged in between this PR and the next one.

@brooksprumo brooksprumo force-pushed the remove-on-drop/field branch from d2dace4 to 6816523 Compare August 7, 2023 16:15
@brooksprumo brooksprumo removed the work in progress This isn't quite right yet label Aug 7, 2023

av.flush().unwrap();
let accounts_len = av.len();
drop(av);
Copy link
Contributor Author

@brooksprumo brooksprumo Aug 7, 2023

Choose a reason for hiding this comment

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

Calling drop on a ManuallyDrop is a clippy lint. So I wrapped the block of code in its own scope to drop av without explicitly calling drop.

@brooksprumo brooksprumo marked this pull request as ready for review August 7, 2023 16:44
Copy link
Contributor

@yhchiang-sol yhchiang-sol left a comment

Choose a reason for hiding this comment

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

Looks good! Just one minor comment.

runtime/src/append_vec.rs Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #32741 (6816523) into master (6eea38d) will decrease coverage by 0.1%.
Report is 2 commits behind head on master.
The diff coverage is 98.1%.

@@            Coverage Diff            @@
##           master   #32741     +/-   ##
=========================================
- Coverage    82.0%    81.9%   -0.1%     
=========================================
  Files         785      785             
  Lines      211192   211185      -7     
=========================================
- Hits       173200   173165     -35     
- Misses      37992    38020     +28     

@brooksprumo brooksprumo merged commit c2dec25 into solana-labs:master Aug 7, 2023
@brooksprumo brooksprumo deleted the remove-on-drop/field branch August 7, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants