Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a93f01f
Run centos and debian workflows on push and PR
igchor Nov 2, 2021
2a8fa60
Adds createPutToken and switches findEviction
byrnedj Feb 4, 2023
c3a4db9
Add memory usage statistics for allocation classes
igchor Jul 6, 2022
2529f0a
Initial multi-tier support implementation (rebased with NUMA and cs p…
igchor Sep 28, 2021
3cc41bd
AC stats multi-tier
byrnedj Jan 17, 2023
bf4c244
This commit contains the additional memory tiers tests
byrnedj Feb 8, 2023
c432df6
This is the additional multi-tier support needed
guptask Nov 14, 2022
4cefc44
added per pool class rolling average latency (upstream PR version)
guptask Jul 21, 2022
1f62a63
added per tier pool class rolling average latency (based on upstream PR)
guptask Jul 21, 2022
489ef20
MM2Q promotion iterators (#1)
byrnedj Aug 9, 2022
048c809
CS Patch Part 2 for mulit-tier cachelib:
byrnedj Feb 7, 2023
ed7b70f
basic multi-tier test based on numa bindings
igchor Dec 30, 2021
94c4974
Aadding new configs to hit_ratio/graph_cache_leader_fobj
vinser52 Jan 27, 2022
afd1456
Do not block reader if a child item is moving
igchor Dec 19, 2022
4f8f425
Background data movement (#20)
byrnedj Oct 21, 2022
6203a95
fix race in moveRegularItemWith sync where insertOrReplace can cause …
byrnedj Feb 16, 2023
6abb498
Fix race in acquire (#68)
igchor Mar 16, 2023
add2e5f
Per tier pool stats (#70)
byrnedj Mar 23, 2023
aedaf97
dummy change to trigger container image rebuild
guptask Mar 28, 2023
1f21fce
Fix token creation and stats (#79)
igchor Apr 27, 2023
9e27d35
Updated the docker gcc version to 12 (#83)
guptask May 9, 2023
da7a6bb
NUMA bindigs support for private memory (#82)
vinser52 May 17, 2023
b5ac462
Do not run cachelib-centos-8-5 on PRs (#85)
igchor Jun 6, 2023
50d3ae5
correct handling for expired items in eviction (#86)
byrnedj Jun 6, 2023
5632d18
Add option to insert items to first free tier (#87)
igchor Jun 8, 2023
09d7bab
Chained item movement between tiers - sync on the parent item (#84)
byrnedj Jun 28, 2023
08d8f33
edit dockerfile
byrnedj Jul 24, 2023
316133c
these submodules work
byrnedj Jul 25, 2023
8d2c390
Track latency of per item eviction/promotion between memory tiers
guptask Jul 28, 2023
b99f2b3
Merge pull request #91 from guptask/tier_eviction_latency
guptask Jul 31, 2023
a14f058
modified the cachebench output to make it friendly for parsing
guptask Aug 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
This is the additional multi-tier support needed
for the compressed ptr changes that were introduced
upstream.
 - Includes later cosmetic changes added by sounak
9cb5c29
  • Loading branch information
guptask authored and byrnedj committed Jul 23, 2023
commit c432df6579c3c2b2a62949ed3b978d3a1ab7ee03
3 changes: 2 additions & 1 deletion cachelib/allocator/CacheAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,7 @@ class CacheAllocator : public CacheBase {
sizeof(typename RefcountWithFlags::Value) + sizeof(uint32_t) +
sizeof(uint32_t) + sizeof(KAllocation)) == sizeof(Item),
"vtable overhead");
// Check for CompressedPtr single/multi tier support
static_assert(32 == sizeof(Item), "item overhead is 32 bytes");

// make sure there is no overhead in ChainedItem on top of a regular Item
Expand Down Expand Up @@ -1936,7 +1937,7 @@ class CacheAllocator : public CacheBase {
}

typename Item::PtrCompressor createPtrCompressor() const {
return allocator_[0 /* TODO */]->createPtrCompressor<Item>();
return typename Item::PtrCompressor(allocator_);
}

// helper utility to throttle and optionally log.
Expand Down
11 changes: 6 additions & 5 deletions cachelib/allocator/memory/AllocationClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ AllocationClass::AllocationClass(ClassId classId,
poolId_(poolId),
allocationSize_(allocSize),
slabAlloc_(s),
freedAllocations_{slabAlloc_.createPtrCompressor<FreeAlloc>()} {
freedAllocations_{slabAlloc_.createSingleTierPtrCompressor<FreeAlloc>()} {
checkState();
}

Expand Down Expand Up @@ -102,7 +102,7 @@ AllocationClass::AllocationClass(
currSlab_(s.getSlabForIdx(*object.currSlabIdx())),
slabAlloc_(s),
freedAllocations_(*object.freedAllocationsObject(),
slabAlloc_.createPtrCompressor<FreeAlloc>()),
slabAlloc_.createSingleTierPtrCompressor<FreeAlloc>()),
canAllocate_(*object.canAllocate()) {
if (!slabAlloc_.isRestorable()) {
throw std::logic_error("The allocation class cannot be restored.");
Expand Down Expand Up @@ -356,9 +356,10 @@ std::pair<bool, std::vector<void*>> AllocationClass::pruneFreeAllocs(
// allocated slab, release any freed allocations belonging to this slab.
// Set the bit to true if the corresponding allocation is freed, false
// otherwise.
FreeList freeAllocs{slabAlloc_.createPtrCompressor<FreeAlloc>()};
FreeList notInSlab{slabAlloc_.createPtrCompressor<FreeAlloc>()};
FreeList inSlab{slabAlloc_.createPtrCompressor<FreeAlloc>()};
FreeList freeAllocs{slabAlloc_.createSingleTierPtrCompressor<FreeAlloc>()};
FreeList notInSlab{slabAlloc_.createSingleTierPtrCompressor<FreeAlloc>()};
FreeList inSlab{slabAlloc_.createSingleTierPtrCompressor<FreeAlloc>()};


lock_->lock_combine([&]() {
// Take the allocation class free list offline
Expand Down
2 changes: 1 addition & 1 deletion cachelib/allocator/memory/AllocationClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class AllocationClass {
struct CACHELIB_PACKED_ATTR FreeAlloc {
using CompressedPtr = facebook::cachelib::CompressedPtr;
using PtrCompressor =
facebook::cachelib::PtrCompressor<FreeAlloc, SlabAllocator>;
facebook::cachelib::SingleTierPtrCompressor<FreeAlloc, SlabAllocator>;
SListHook<FreeAlloc> hook_{};
};

Expand Down
65 changes: 59 additions & 6 deletions cachelib/allocator/memory/CompressedPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ namespace cachelib {

class SlabAllocator;

template <typename PtrType, typename AllocatorContainer>
class PtrCompressor;

// This CompressedPtr makes decompression fast by staying away from division and
// modulo arithmetic and doing those during the compression time. We most often
// decompress a CompressedPtr than compress a pointer while creating one. This
// modulo arithmetic and doing those during the compression time. We most often
// decompress a CompressedPtr than compress a pointer while creating one. This
// is used for pointer compression by the memory allocator.

// We compress pointers by storing the tier index, slab index and alloc index of
Expand Down Expand Up @@ -173,12 +176,14 @@ class CACHELIB_PACKED_ATTR CompressedPtr {
}

friend SlabAllocator;
template <typename CPtrType, typename AllocatorContainer>
friend class PtrCompressor;
};

template <typename PtrType, typename AllocatorT>
class PtrCompressor {
class SingleTierPtrCompressor {
public:
explicit PtrCompressor(const AllocatorT& allocator) noexcept
explicit SingleTierPtrCompressor(const AllocatorT& allocator) noexcept
: allocator_(allocator) {}

const CompressedPtr compress(const PtrType* uncompressed) const {
Expand All @@ -190,17 +195,65 @@ class PtrCompressor {
allocator_.unCompress(compressed, false /* isMultiTiered */));
}

bool operator==(const PtrCompressor& rhs) const noexcept {
bool operator==(const SingleTierPtrCompressor& rhs) const noexcept {
return &allocator_ == &rhs.allocator_;
}

bool operator!=(const PtrCompressor& rhs) const noexcept {
bool operator!=(const SingleTierPtrCompressor& rhs) const noexcept {
return !(*this == rhs);
}

private:
// memory allocator that does the pointer compression.
const AllocatorT& allocator_;
};

template <typename PtrType, typename AllocatorContainer>
class PtrCompressor {
public:
explicit PtrCompressor(const AllocatorContainer& allocators) noexcept
: allocators_(allocators) {}

const CompressedPtr compress(const PtrType* uncompressed) const {
if (uncompressed == nullptr)
return CompressedPtr{};

TierId tid;
for (tid = 0; tid < allocators_.size(); tid++) {
if (allocators_[tid]->isMemoryInAllocator(
static_cast<const void*>(uncompressed)))
break;
}

bool isMultiTiered = allocators_.size() > 1;
auto cptr = allocators_[tid]->compress(uncompressed, isMultiTiered);
if (isMultiTiered) { // config has multiple tiers
cptr.setTierId(tid);
}
return cptr;
}

PtrType* unCompress(const CompressedPtr compressed) const {
if (compressed.isNull()) {
return nullptr;
}
bool isMultiTiered = allocators_.size() > 1;
auto& allocator = *allocators_[compressed.getTierId(isMultiTiered)];
return static_cast<PtrType*>(
allocator.unCompress(compressed, isMultiTiered));
}

bool operator==(const PtrCompressor& rhs) const noexcept {
return &allocators_ == &rhs.allocators_;
}

bool operator!=(const PtrCompressor& rhs) const noexcept {
return !(*this == rhs);
}

private:
// memory allocator that does the pointer compression.
const AllocatorContainer& allocators_;
};
} // namespace cachelib
} // namespace facebook
11 changes: 6 additions & 5 deletions cachelib/allocator/memory/MemoryAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,13 @@ class MemoryAllocator {
using CompressedPtr = facebook::cachelib::CompressedPtr;
template <typename PtrType>
using PtrCompressor =
facebook::cachelib::PtrCompressor<PtrType, SlabAllocator>;

facebook::cachelib::PtrCompressor<PtrType,
std::vector<std::unique_ptr<MemoryAllocator>>>;

template <typename PtrType>
PtrCompressor<PtrType> createPtrCompressor() {
return slabAllocator_.createPtrCompressor<PtrType>();
}
using SingleTierPtrCompressor =
facebook::cachelib::PtrCompressor<PtrType,
SlabAllocator>;

// compress a given pointer to a valid allocation made out of this allocator
// through an allocate() or nullptr. Calling this otherwise with invalid
Expand Down
4 changes: 2 additions & 2 deletions cachelib/allocator/memory/SlabAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ class SlabAllocator {
}

template <typename PtrType>
PtrCompressor<PtrType, SlabAllocator> createPtrCompressor() const {
return PtrCompressor<PtrType, SlabAllocator>(*this);
SingleTierPtrCompressor<PtrType, SlabAllocator> createSingleTierPtrCompressor() const {
return SingleTierPtrCompressor<PtrType, SlabAllocator>(*this);
}

// returns starting address of memory we own.
Expand Down
1 change: 1 addition & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Newline separated list of tests to ignore
BLACKLIST="allocator-test-NavySetupTest
allocator-test-NvmCacheTests
shm-test-test_page_size"

if [ "$1" == "long" ]; then
Expand Down