-
Notifications
You must be signed in to change notification settings - Fork 304
First set of changes to cache configuration API to enable multi-tier caches #138
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
Conversation
…ement features discussed here: pmem#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced.
@jiayuebao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix the build failure by adding MemoryTierCacheConfig.h
to "cachelib/allocator/TARGETS" and CacheAllocatorConfigTest.cpp
to "cachelib/allocator/tests/TARGETS"?
MemoryTierCacheConfig() = default; | ||
}; | ||
} // namespace cachelib | ||
} // namespace facebook No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a new line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…nd of MemoryTierCacheConfig.h
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
@jiayuebao I don't seem to have access/visibility to TARGETS files. Could you give me more specific instructions how I can address your request? |
// all tier sizes | ||
CacheAllocatorConfig& configureMemoryTiers(const MemoryTierConfigs& configs); | ||
|
||
// Sets total cache size and configures cache memory tiers. This method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this override the previously set cache size ? And by cache size we mean the DRAM cache size ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By cache size we mean "total cache size" which is the sum of all memory tier sizes. By default there's only one DRAM memory tier whose size matches total cache size.
I decided to delete this 2 argument configureMemoryTiers method.
// cachePersistence() | ||
CacheAllocatorConfig& usePosixForShm(); | ||
|
||
// Configures cache memory tiers. Accepts vector of MemoryTierCacheConfig. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a description of what Memory tiers refers to here ? There is already the notion of tiers through hybrid cache. It would help if we can point to some documentation about the memory tier here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this method's description to list possible memory types for memory tiers. In the future, we could convert this write-up #102 into a documentation section to refer to.
@victoria-mcgrath I just realized the TARGETS files aren't synced to the Github. Let me check whether we should modify the file internally on our end. |
… added validation funciton and a test for tier sizes
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
@jiayuebao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
"It's not allowed to enable both RemoveCB and ItemDestructor."); | ||
} | ||
|
||
validateMemoryTierSizes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victoria-mcgrath Adding this line will cause the existing tests to fail. Can we only introduce the multi-tier cache config in this PR without affecting the existing use cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiayuebao I fixed failing tests by updating default DRAM tier to have size that matches default total cache size. In general, changes in this PR shouldn't break current DRAM cache configuration. I ran a subset of unit tests locally and confirmed that they passed. Please let me know of remaining failing tests if any.
|
||
template <typename T> | ||
CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::setCacheSize(size_t _size) { | ||
CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::setCacheSizeImpl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we not change setCacheSize
function directly as other users are using this function without setting the multi-tier cache config? Can we add a new setCacheSize
function only for multi-tier caches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR includes support for current DRAM only cache configuration which can be configured as a single tier cache, and it is a default configuration (line #608). Changing setCacheSize to support 1 or more tiers is one of the changes required to initiate multi-tier support in general. Could you elaborate more on what you meant and advantages of having 2 separate methods?
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
Co-authored-by: Jiayue Bao <40874685+jiayuebao@users.noreply.github.com>
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
…ze; deleted unused code.
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
@jiayuebao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Hi @victoria-mcgrath: The change will still break tons of our internal tests. The reason is not all cachelib user cases are calling BTW, can I know whether the test failure is visible from your side? |
Hey @victoria-mcgrath any update on the fix? |
@jiayuebao The changes in the config API aren't supposed to be breaking the existing functionality and no additional API should be required: current DRAM cache config is going to be configured as a multi-tiered cache with a single tier. However, setting the total cache size without calling setCacheSize is problematic for multi-tier enabling. I can fix the failing tests (I believe I only see failures from compact-cache-test-CCacheTests, but I never run the entire suite, just a large subset) by either making them call setCacheSize (after making "size" private) or I can change a check in validation method (see last if-else) to maintain compatibility with the existing code:
For the later option, I'd need to omit const-ness from validate method though. EDIT: there's a 3rd option: delete validateMemoryTierSizes all together but it seems even more messy. What do you think? |
@jiayuebao I just discussed this problem with @igchor and he had a much better idea to work around this problem: we can only allow setting ratios of tiers and calculate their sizes only when we actually allocate memory. Then, the timing and method of setting the total cache size shouldn't seem to matter. In our internal experiments, we never needed to specify tier sizes explicitly, so this has been so far a somewhat redundant feature anyways. We'll work on the change and share it here. |
@jiayuebao and @igchor: please review the latest changes that disable size property for tiers. |
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
2572a26
to
441c35a
Compare
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
Will let @igchor review first. If things look good, I will re-import the change again. |
@victoria-mcgrath has updated the pull request. You must reimport the pull request before landing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
@jiayuebao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
…caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5
…caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5
…caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5
* #75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com>
* #75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com>
* pmem#75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com>
* #75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com>
* pmem#75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com>
author Chorazewicz, Igor <igor.chorazewicz@intel.com> 1632834667 +0200 committer Daniel Byrne <byrnedj12@gmail.com> 1671070203 -0800 Initial multi-tier support implementation Extend CompressedPtr to work with multiple tiers Now it's size is 8 bytes intead of 4. Original CompressedPtr stored only some offset with a memory Allocator. For multi-tier implementation, this is not enough. We must also store tierId and when uncompressing, select a proper allocator. An alternative could be to just resign from CompressedPtr but they are leveraged to allow the cache to be mapped to different addresses on shared memory. Changing CompressedPtr impacted CacheItem size - it increased from 32 to 44 bytes. Implemented async Item movement between tiers (with corrected behaivour of tryEvictToNextMemoryTier). Fix ReaperSkippingSlabTraversalWhileSlabReleasing test The issue was caused by incorrect behaviour of the CacheAllocator<CacheTrait>::tryEvictToNextMemoryTier method in case the evicted item is expired. We cannot simply return a handle to it, but we need to remove it from the access container and MM container. Enable workarounds in tests Add basic multi-tier test Set correct size for each memory tier Do not compensate for rounding error when calculating tier sizes (pmem#43) Compensation results in ratios being different than originially specified. Fixed total cache size in CacheMemoryStats (pmem#38) Return a sum of sizes of each tier instead of just 1st tier's size. Issue75 rebased (pmem#88) * pmem#75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com> Fix eviction flow and removeCb calls Without this fix removeCb called even in case when Item is moved between tiers. Fix issue with "Destorying an unresolved handle" The issue happened when ReadHandleImpl ctor needs to destroy waitContext_ because addWaitContextForMovingItem() returns false. So before destroying waitContext_ we are calling discard method to notify ~ItemWaitContext() that Item is ready. Fix slab release code Get tier id of item before calling any function on allocator (which needs the tierID).
* New class MemoryTierCacheConfig allows to configure a memory tier. Setting tier size and location of a file for file-backed memory are supported in this initial implementation; * New member, vector of memory tiers, is added to class CacheAllocatorConfig. * New test suite, chelib/allocator/tests/MemoryTiersTest.cpp, demonstrates the usage of and tests extended config API. Integrate Memory Tier config API with CacheAllocator. Enabled memory tier config API for cachebench. Assumes NUMA bindings support - this commit was done before tiering support enabled. fix memBind call replaces Add MemoryTierCacheConfig::fromShm() (commit 1c7c15d) Move validation code for memory tiers to validate() method and convert ratios to sizes lazily Do not compensate for rounding error when calculating tier sizes (pmem#43) Compensation results in ratios being different than originially specified. Fixed total cache size in CacheMemoryStats (pmem#38) Return a sum of sizes of each tier instead of just 1st tier's size. Issue75 rebased (pmem#88) * pmem#75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com>
* New class MemoryTierCacheConfig allows to configure a memory tier. Setting tier size and location of a file for file-backed memory are supported in this initial implementation; * New member, vector of memory tiers, is added to class CacheAllocatorConfig. * New test suite, chelib/allocator/tests/MemoryTiersTest.cpp, demonstrates the usage of and tests extended config API. Integrate Memory Tier config API with CacheAllocator. Enabled memory tier config API for cachebench. Assumes NUMA bindings support - this commit was done before tiering support enabled. fix memBind call replaces Add MemoryTierCacheConfig::fromShm() (commit 1c7c15d) Move validation code for memory tiers to validate() method and convert ratios to sizes lazily Do not compensate for rounding error when calculating tier sizes (pmem#43) Compensation results in ratios being different than originially specified. Fixed total cache size in CacheMemoryStats (pmem#38) Return a sum of sizes of each tier instead of just 1st tier's size. Issue75 rebased (pmem#88) * pmem#75: Use actual tier sizes (rounded down to slab size and decreased by header size) when creating new memory pools * Added getPoolSize method to calculate combined pool size for all tiers; added pool size validation to tests * Explicitly specified type for totalCacheSize to avoid overflow * Minor test change * Reworked tests * Minor change * Deleted redundant tests * Deleted unused constant * First set of changes to cache configuration API to enable multi-tier caches (facebook#138) Summary: These changes introduce per-tier cache configuration required to implement features discussed here: facebook#102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced. Pull Request resolved: facebook#138 Reviewed By: therealgymmy Differential Revision: D36189766 Pulled By: jiayuebao fbshipit-source-id: 947aa0cd800ea6accffc1b7b6b0c9693aa7fc0a5 Co-authored-by: Victoria McGrath <victoria.mcgrath@intel.com>
…222) Summary: This PR is to add support for NUMA bindings to the memory tier config that was upstreamed in #138 A quick summary of the PR is: - Add memory tier configs to cache allocator based on NUMA bindings - Add in MemoryTier tests - Add getPoolSize() and inline the calculate tier size for tests - Increase max number of tiers to 2 for tiers tests Pull Request resolved: #222 Reviewed By: haowu14 Differential Revision: D47101857 Pulled By: therealgymmy fbshipit-source-id: 346b78a561e3badb5e2c403c0dcf3c215264c31c
These changes introduce per-tier cache configuration required to implement features discussed here: #102. These specific changes enable single DRAM tier configs only which are compatible with the current version of cachelib. Configuration API will be expanded as multi-tier changes in other parts of the library are introduced.