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

Refactors BucketStorage::map_open_file() #2141

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

brooksprumo
Copy link

@brooksprumo brooksprumo commented Jul 15, 2024

Problem

BucketStorage::map_open_file() could be a touch simpler, and have some logic/error handling improved.

Summary of Changes

  • Improve error handling/logging
  • Simplify return value handling

@brooksprumo brooksprumo self-assigned this Jul 15, 2024
@brooksprumo brooksprumo force-pushed the bucket-map/map-open-file branch from 48fb732 to 817cadc Compare July 15, 2024 18:01
@brooksprumo brooksprumo force-pushed the bucket-map/map-open-file branch from 817cadc to dc514a1 Compare July 16, 2024 21:20
@brooksprumo brooksprumo marked this pull request as ready for review July 16, 2024 23:54
@@ -427,23 +426,21 @@ impl<O: BucketOccupied> BucketStorage<O> {
.fetch_add(measure_flush.end_as_us(), Ordering::Relaxed);
}
let mut measure_mmap = Measure::start("measure_mmap");
let res = unsafe { MmapMut::map_mut(&data) };
if let Err(e) = res {
let mmap = unsafe { MmapMut::map_mut(&data) }.unwrap_or_else(|err| {

Choose a reason for hiding this comment

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

this adds a lot more code inside unsafe. I'm sure you're aware. It is all error handling code.

Copy link
Author

Choose a reason for hiding this comment

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

I put the .unwrap_or_else after the unsafe block ends. I don't think think that runs as unsafe then, right?

Copy link

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

lgtm

@brooksprumo brooksprumo merged commit b0ec23d into anza-xyz:master Jul 19, 2024
41 checks passed
@brooksprumo brooksprumo deleted the bucket-map/map-open-file branch July 19, 2024 13:58
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