Skip to content

Conversation

pdillinger
Copy link
Contributor

Summary: Add two type aliases for Cache: BlockCache and GeneralCache, and add LRUCacheOptions::MakeSharedGeneralCache(). This will ease upgrade to an intended future change to separate the cache API between block cache and other (general) uses, including row cache. Separating the APIs will make it easier to expose more details of block caching for customization. For example, it would be nice to pass the file unique ID and offset as the logical cache key instead of using a Slice, which could facilitate some file-specific customizations in block cache. This would also make it clear that HyperClockCache is not usable as a general cache, because it can only deal with fixed-size block cache keys.

block_cache, row_cache, and blob_cache are the uses of Cache in the public API. blob_cache should be able to use BlockCache while row_cache is a GeneralCache user, as its keys are of arbitrary size.

Test Plan: see updated unit test.

Summary: Add two type aliases for Cache: BlockCache and GeneralCache,
and add LRUCacheOptions::MakeSharedGeneralCache(). This will ease
upgrade to an intended future change to separate the cache API between
block cache and other (general) uses, including row cache. Separating
the APIs will make it easier to expose more details of block caching for
customization. For example, it would be nice to pass the file unique ID
and offset as the logical cache key instead of using a Slice, which
could facilitate some file-specific customizations in block cache. This
would also make it clear that HyperClockCache is not usable as a general
cache, because it can only deal with fixed-size block cache keys.

block_cache, row_cache, and blob_cache are the uses of Cache in the
public API. blob_cache should be able to use BlockCache while row_cache
is a GeneralCache user, as its keys are of arbitrary size.

Test Plan: see updated unit test.
@facebook-github-bot
Copy link
Contributor

@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@anand1976 anand1976 left a comment

Choose a reason for hiding this comment

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

LGTM

// and make a factory function for general caches. Encourage users of row_cache
// (not common) to switch to the factory function for general caches.
// * Phase 2 - Split off GenericCache as its own class, removing secondary
// cache support features and more from the API to simplify it. Between Phase 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we end up with two similar implementations of LRU cache, one for general and one for block cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe one implementation will implement both interfaces. I'll try to work it that way and see if I run into trouble.

@facebook-github-bot
Copy link
Contributor

@pdillinger has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@pdillinger merged this pull request in 4067aca.

facebook-github-bot pushed a commit that referenced this pull request Jul 19, 2023
Summary:
An internal user wants to implement a key-aware row cache policy. For that, they need to know the components of the cache key, especially the user key component. With a specialized `RowCache` interface, we will be able to tell them the components so they won't have to make assumptions about our internal key schema.

This PR prepares for the specialized `RowCache` interface by updating the migration plan of #11450. I added a release note for the removed APIs and didn't mention the added ones for now.

Pull Request resolved: #11620

Reviewed By: pdillinger

Differential Revision: D47536962

Pulled By: ajkr

fbshipit-source-id: bbee0fc4ad67fc699a66b8f2b4ea4544dd003691
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants