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

NS-CACHE: Eviction from the cache #6086

Merged
merged 1 commit into from
Aug 21, 2020

Conversation

guptsanj
Copy link
Contributor

@guptsanj guptsanj commented Jul 13, 2020

Explain the changes

Cached chunks are evicted when a namespace bucket with cache starts to fill up.
The tier ttf worker will periodically perform the eviction.
When bucket reaches a predefined limit, entries are no longer cached
Any in transit objects/chunks are also dropped.

Issues: Fixed #xxx / Gap #xxx

Testing Instructions:

@guptsanj guptsanj changed the title Garbage Tier Garbage Tier - WIP Jul 16, 2020
@guptsanj guptsanj force-pushed the sgupta/garbage-tier-2 branch 8 times, most recently from 1f3b4e2 to 2ae7368 Compare July 20, 2020 15:31
@guptsanj guptsanj requested a review from nb-ohad July 20, 2020 15:49
@guptsanj guptsanj force-pushed the sgupta/garbage-tier-2 branch 2 times, most recently from cd39499 to ea643ab Compare July 20, 2020 18:01
@guptsanj guptsanj changed the title Garbage Tier - WIP Garbage Tier for noobaa cache bucket Jul 21, 2020
src/server/object_services/map_builder.js Outdated Show resolved Hide resolved
src/server/object_services/map_builder.js Show resolved Hide resolved
src/server/object_services/map_deleter.js Outdated Show resolved Hide resolved
src/sdk/namespace_cache.js Outdated Show resolved Hide resolved
src/sdk/namespace_cache.js Outdated Show resolved Hide resolved
src/server/object_services/map_server.js Outdated Show resolved Hide resolved
@guymguym guymguym changed the title Garbage Tier for noobaa cache bucket [NS-CACHE] Eviction from cache Aug 17, 2020
@guymguym guymguym changed the title [NS-CACHE] Eviction from cache NS-CACHE: Eviction from the cache Aug 17, 2020
@guymguym guymguym added the Comp-Namespace Namespace buckets related label Aug 17, 2020
@guptsanj guptsanj force-pushed the sgupta/garbage-tier-2 branch 2 times, most recently from d9a32c8 to c4d8a39 Compare August 19, 2020 04:15
Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

Still reviewing, but sending out my comments so far.

src/api/scrubber_api.js Outdated Show resolved Hide resolved
src/sdk/map_api_types.js Outdated Show resolved Hide resolved
src/server/object_services/map_deleter.js Outdated Show resolved Hide resolved
src/server/bg_services/tier_ttf_worker.js Outdated Show resolved Hide resolved
src/server/bg_services/tier_ttf_worker.js Outdated Show resolved Hide resolved
src/server/object_services/map_deleter.js Outdated Show resolved Hide resolved
src/server/object_services/map_builder.js Outdated Show resolved Hide resolved
src/server/object_services/map_deleter.js Outdated Show resolved Hide resolved
src/server/object_services/map_builder.js Outdated Show resolved Hide resolved
@guymguym
Copy link
Member

Another note was about the call to usage_aggregator.get_bandwidth_report() in the worker here:

const reports = await usage_aggregator.get_bandwidth_report({
bucket: bucket._id,
since: now - (1000 * 60 * 60),
till: now,
time_range: 'hour'
});

@nb-ohad suggested to use lower time_range and sum up the results.

src/sdk/map_api_types.js Outdated Show resolved Hide resolved
src/server/bg_services/tier_ttf_worker.js Outdated Show resolved Hide resolved
src/server/bg_services/tier_ttf_worker.js Outdated Show resolved Hide resolved
src/server/bg_services/tier_ttf_worker.js Outdated Show resolved Hide resolved
src/server/object_services/map_deleter.js Outdated Show resolved Hide resolved
src/server/object_services/map_deleter.js Show resolved Hide resolved
Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

@guptsanj See changes requested. Please let me know if I can help.

src/server/object_services/map_builder.js Outdated Show resolved Hide resolved
src/server/object_services/map_builder.js Outdated Show resolved Hide resolved
@guymguym guymguym requested a review from nb-ohad August 20, 2020 20:01
@guymguym guymguym dismissed nb-ohad’s stale review August 20, 2020 20:23

Comments are not relevant in updated PR

@guymguym
Copy link
Member

@jackyalbo Please review and change your review to approved if you have no additional comments - we are trying to complete this PR this week. Thanks

@guptsanj guptsanj force-pushed the sgupta/garbage-tier-2 branch 3 times, most recently from 4ab7236 to b293934 Compare August 21, 2020 03:37
Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

Hi @guptsanj Good job, this is almost done.
I found a couple more things - see below.
Also what about usage_aggregator.get_bandwidth_report() - didn't you need to change it?

src/server/bg_services/tier_ttf_worker.js Outdated Show resolved Hide resolved
src/server/object_services/map_builder.js Show resolved Hide resolved
src/server/object_services/map_builder.js Outdated Show resolved Hide resolved
Triggered in the tier ttf worker

Signed-off-by: Sanjeev Gupta <guptsanj@us.ibm.com>
@guptsanj
Copy link
Contributor Author

Hi @guymguym

Re: Also what about usage_aggregator.get_bandwidth_report() - didn't you need to change it?
I will start looking at this today.

// any attempt is made to delete the objects.
if (this.evict) {
const objects_to_gc = _.uniq(loaded_chunks_db.flatMap(chunk => chunk.objects))
.filter(obj => Date.now() - obj.create_time.getTime() > config.NAMESPACE_CACHING.MIN_OBJECT_AGE_FOR_GC);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@guymguym Should we not do this cached object aging check at the start of the map builder for the eviction case? This check is just marking object entries as deleted when they are aged out AND objects have no parts.
The chunks, parts and blocks related to eviction have already been deleted by this point.

Copy link
Member

@guymguym guymguym Aug 21, 2020

Choose a reason for hiding this comment

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

Good question - here are my thoughts:

For chunks (with their parts and blocks) we trigger eviction based on capacity and evict chunks from the cache based on LRU. FIFO is even easier to implement just by not moving chunks to the front of the LRU on hit - and FIFO is age based. So if we will prefer simple age based vs access based caching, we can do that - actually we should just add this for dev/test.

For objects_md cleanup - keep in mind that even if we are limited on cache capacity and have to evict, it is still very much likely that cached object_mds have not been deleted or overwritten in the hub, so keeping them is not a bad thing at all. But we do need to evict eventually if the workload will read too many of these to the cache than we can store in the DB. Today we do not have a capacity limit for object_mds and we do not order them in LRU. However we can easily iterate object_mds in FIFO order by traversing the _id index in order or creation in the cache and then check if this object has no parts and then delete.

Ultimately I think object_md cleanup calls for a separate worker - because the iteration subject and order are completely different than tier_ttf_worker. In its own worker we should check how close we are to the object_mds limit we can store in the DB (either config or calculate based on PV), and cleanup in FIFO order.

For now I thought we can piggy back the chunks eviction, BUT adding the age condition I suggested is presenting an issue - if we evict all chunks/parts of an object but it is too young and we filter it out from objects_to_gc, we may never come back to evict more chunks for this same object_md and it will never be evicted. So I would remove the filter for now, but in any case to make it work well we need to move this to its own worker.

Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

@guptsanj Great work. See my comment above - I think removing the age filter for objects_to_gc is better, but in any case this is not a real issue and we can go ahead with this PR and improve object_md eviction in next PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Comp-Namespace Namespace buckets related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants