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

Bump dependency on lru to from version 0.7.5 to version 0.9.0. #1755

Merged
merged 1 commit into from
Jan 10, 2023
Merged

Bump dependency on lru to from version 0.7.5 to version 0.9.0. #1755

merged 1 commit into from
Jan 10, 2023

Conversation

adamreichold
Copy link
Collaborator

No description provided.

@fulmicoton
Copy link
Collaborator

Thank you!

@fulmicoton
Copy link
Collaborator

Thank you! @adamreichold.
@evanxg852000 can you review?

evanxg852000
evanxg852000 previously approved these changes Jan 6, 2023
@evanxg852000 evanxg852000 dismissed their stale review January 6, 2023 07:42

I am just not keen on wrapping the cache in Option<...>

Copy link
Collaborator

@evanxg852000 evanxg852000 left a comment

Choose a reason for hiding this comment

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

Nice work 👍
Please can you avoid wrapping the cache in Option, or let me know if there are other reasons apart from using NonZeroUsize

cache: Mutex<LruCache<usize, Block>>,
cache_hits: Arc<AtomicUsize>,
cache_misses: Arc<AtomicUsize>,
cache: Option<Mutex<LruCache<usize, Block>>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this option is just for being able to use NonZeroUsize. I think it's simpler to stick to cache: Mutex<LruCache<usize, Block>>. If we want to forbid cache size of zero, an assert can be appropriate.

Copy link
Collaborator Author

@adamreichold adamreichold Jan 6, 2023

Choose a reason for hiding this comment

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

I actually started by propagating the use of NonZeroUsize through to the code base, but there are places where, indirectly, zero-size caches are created. To continue to support this, I chose the Option<..> layer which is not so much about using NonZeroUsize but more about supporting zero-sized caches which lru does just not support any more.

Personally, I see two viable options:

  • Using Option<..> to continue supporting zero-sized caches.
  • Propagate the usize -> NonZeroUsize type change throughout the API and change any callers to use at least cache size one.

Just asserting a non-zero cache might lead to hard to diagnose panics IMHO as there are multiple layers of indirection between constructing readers, writers, etc. and the usage of LruCache.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, to keep the change in scope let's stick with Option<...> then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have the second alternative ready in a branch. So if you want that, I can propose that as a follow-up PR since I do agree that having the local change first is much easier to review.

src/store/reader.rs Show resolved Hide resolved
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.

3 participants