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

Report to Log the Index size per CF - LRU Cache Only (#338) #368

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

udi-speedb
Copy link
Contributor

No description provided.

@udi-speedb udi-speedb linked an issue Jan 17, 2023 that may be closed by this pull request
Copy link
Contributor

@speedbmike speedbmike left a comment

Choose a reason for hiding this comment

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

Many small changes that will make future rebases more difficult. Need to make sure that when HyperClockCache is added instead of ClockCache this functionality won't be left out

const Slice& key, void* value, const CacheItemHelper* helper,
size_t charge, Handle** handle = nullptr,
Priority priority = Priority::LOW,
Cache::ItemOwnerId item_owner_id = kUnknownItemId) override;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is default value needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is default value needed here?
This function overrides the one in Cache, which does have a default value. If I want to allow the user to call Insert() without explicitly specifying the item_owner_id, it must have a default (and It should be the same default). The fact that the base class has a default, doesn't make this inherit that behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As for your comment about many small changes. I agree. However, since I am changing the signature of the Insert function and the signature of the callback function on which the solution is based, I see no other option.
If, in addition, I will not use a default value for the item_owner_id, there will be even more changes in calls that currently may stay as is because that default saves us the need to change them as well.

cache/cache.cc Outdated
std::lock_guard<std::mutex> lock(free_ids_mutex_);
// There must be at least 1 list element on the free_ids_ list since
// we num_free_ids_ must have been >= 1 on entry if we got here.
// Asserting to catch the bug during testing, however, this is a
Copy link
Contributor

Choose a reason for hiding this comment

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

All that code is to avoid locking mutex when checking if free list is non-empty upfront? But isn't allocation itself very rare? And what happens when another thread changes these values at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the code if for that. The code is supposed to be thread safe (under the assumptions described in the comments). Please let me know if you do find a bug in it.
However, if you feel I should just use the mutex at the start since this is a rare event, that will simplify the code and the code may be removed.

@@ -468,7 +469,7 @@ void LRUCacheShard::Promote(LRUHandle* e) {
e->IsHighPri() ? Cache::Priority::HIGH : Cache::Priority::LOW;
s = Insert(e->key(), e->hash, /*value=*/nullptr, 0,
/*deleter=*/nullptr, /*helper=*/nullptr, /*handle=*/nullptr,
priority);
priority, Cache::kUnknownItemId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it unknown here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I have changed this to pass the item owner id of the promoted handle (assuming that was what bothered you)

db/table_cache.cc Show resolved Hide resolved
speedbmike
speedbmike previously approved these changes Jan 29, 2023
@udi-speedb
Copy link
Contributor Author

@erez-speedb, @Yuval-Ariel I have just noticed that I haven't squashed the commits.
I will now rebase on latest origin/main, squash, and (force) push

@udi-speedb
Copy link
Contributor Author

@speedbmike - I apologize. I did a test on this PR together with @maxb-io. @maxb-io changed the policy to invalidate a pr approval once new commits are pushed to the pr. So I pushed a dummy commit and now I have forced pushed the branch again without the dummy commit.
However, I think you are supposed to re-approve it

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.

Add index size report per column family
3 participants