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
added per pool class rolling average latency (upstream PR version)
fix for rolling stats (on multi-tier to be followed by multi-tier rolling stats
implementation in the following commit)
  • Loading branch information
guptask authored and byrnedj committed Jul 23, 2023
commit 4cefc4434e3f78b1caff9bb5e425083db324f6be
12 changes: 9 additions & 3 deletions cachelib/allocator/CacheAllocator-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ CacheAllocator<CacheTrait>::allocateInternalTier(TierId tid,

// the allocation class in our memory allocator.
const auto cid = allocator_[tid]->getAllocationClassId(pid, requiredSize);
util::RollingLatencyTracker rollTracker{
(*stats_.classAllocLatency)[pid][cid]};

// TODO: per-tier
(*stats_.allocAttempts)[pid][cid].inc();
Expand Down Expand Up @@ -478,8 +480,9 @@ CacheAllocator<CacheTrait>::allocateChainedItemInternal(
const auto pid = allocator_[tid]->getAllocInfo(parent->getMemory()).poolId;
const auto cid = allocator_[tid]->getAllocationClassId(pid, requiredSize);

// TODO: per-tier? Right now stats_ are not used in any public periodic
// worker
util::RollingLatencyTracker rollTracker{
(*stats_.classAllocLatency)[pid][cid]};

(*stats_.allocAttempts)[pid][cid].inc();

void* memory = allocator_[tid]->allocate(pid, requiredSize);
Expand Down Expand Up @@ -2468,7 +2471,10 @@ ACStats CacheAllocator<CacheTrait>::getACStats(TierId tid,
ClassId classId) const {
const auto& pool = allocator_[tid]->getPool(poolId);
const auto& ac = pool.getAllocationClass(classId);
return ac.getStats();

auto stats = ac.getStats();
stats.allocLatencyNs = (*stats_.classAllocLatency)[poolId][classId];
return stats;
}

template <typename CacheTrait>
Expand Down
4 changes: 3 additions & 1 deletion cachelib/allocator/CacheStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ void Stats::init() {
initToZero(*fragmentationSize);
initToZero(*chainedItemEvictions);
initToZero(*regularItemEvictions);

classAllocLatency = std::make_unique<PerPoolClassRollingStats>();
}

template <int>
struct SizeVerify {};

void Stats::populateGlobalCacheStats(GlobalCacheStats& ret) const {
#ifndef SKIP_SIZE_VERIFY
SizeVerify<sizeof(Stats)> a = SizeVerify<16176>{};
SizeVerify<sizeof(Stats)> a = SizeVerify<16192>{};
std::ignore = a;
#endif
ret.numCacheGets = numCacheGets.get();
Expand Down
8 changes: 8 additions & 0 deletions cachelib/allocator/CacheStatsInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cachelib/allocator/Cache.h"
#include "cachelib/allocator/memory/MemoryAllocator.h"
#include "cachelib/common/AtomicCounter.h"
#include "cachelib/common/RollingStats.h"

namespace facebook {
namespace cachelib {
Expand Down Expand Up @@ -229,6 +230,13 @@ struct Stats {
std::unique_ptr<PerPoolClassAtomicCounters> chainedItemEvictions{};
std::unique_ptr<PerPoolClassAtomicCounters> regularItemEvictions{};

using PerPoolClassRollingStats =
std::array<std::array<util::RollingStats, MemoryAllocator::kMaxClasses>,
MemoryPoolManager::kMaxPools>;

// rolling latency tracking for every alloc class in every pool
std::unique_ptr<PerPoolClassRollingStats> classAllocLatency{};

// Eviction failures due to parent cannot be removed from access container
AtomicCounter evictFailParentAC{0};

Expand Down
4 changes: 4 additions & 0 deletions cachelib/allocator/memory/MemoryAllocatorStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <unordered_map>

#include "cachelib/allocator/memory/Slab.h"
#include "cachelib/common/RollingStats.h"

namespace facebook {
namespace cachelib {
Expand Down Expand Up @@ -47,6 +48,9 @@ struct ACStats {
// true if the allocation class is full.
bool full;

// Rolling allocation latency (in ns)
util::RollingStats allocLatencyNs;

constexpr unsigned long long totalSlabs() const noexcept {
return freeSlabs + usedSlabs;
}
Expand Down
6 changes: 4 additions & 2 deletions cachelib/cachebench/cache/CacheStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ struct Stats {
: stats.usageFraction();

out << folly::sformat(
"pid{:2} cid{:4} {:8.2f}{} usageFraction: {:4.2f}", pid, cid,
allocSize, allocSizeSuffix, acUsageFraction)
"tid{:2} pid{:2} cid{:4} {:8.2f}{} usageFraction: {:4.2f} "
"rollingAvgAllocLatency: {:8.2f}ns",
tid, pid, cid, allocSize, allocSizeSuffix, acUsageFraction,
stats.allocLatencyNs.estimate())
<< std::endl;
});
}
Expand Down
90 changes: 90 additions & 0 deletions cachelib/common/RollingStats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <folly/Range.h>
#include <folly/logging/xlog.h>

#include "cachelib/common/Utils.h"

namespace facebook {
namespace cachelib {
namespace util {

class RollingStats {
public:
// track latency by taking the value of duration directly.
void trackValue(double value) {
// This is a highly unlikely scenario where
// cnt_ reaches numerical limits. Skip update
// of the rolling average anymore.
if (cnt_ == std::numeric_limits<uint64_t>::max()) {
cnt_ = 0;
return;
}
auto ratio = static_cast<double>(cnt_) / (cnt_ + 1);
avg_ *= ratio;
++cnt_;
avg_ += value / cnt_;
}

// Return the rolling average.
double estimate() { return avg_; }

private:
double avg_{0};
uint64_t cnt_{0};
};

class RollingLatencyTracker {
public:
explicit RollingLatencyTracker(RollingStats& stats)
: stats_(&stats), begin_(std::chrono::steady_clock::now()) {}
RollingLatencyTracker() {}
~RollingLatencyTracker() {
if (stats_) {
auto tp = std::chrono::steady_clock::now();
auto diffNanos =
std::chrono::duration_cast<std::chrono::nanoseconds>(tp - begin_)
.count();
stats_->trackValue(static_cast<double>(diffNanos));
}
}

RollingLatencyTracker(const RollingLatencyTracker&) = delete;
RollingLatencyTracker& operator=(const RollingLatencyTracker&) = delete;

RollingLatencyTracker(RollingLatencyTracker&& rhs) noexcept
: stats_(rhs.stats_), begin_(rhs.begin_) {
rhs.stats_ = nullptr;
}

RollingLatencyTracker& operator=(RollingLatencyTracker&& rhs) noexcept {
if (this != &rhs) {
this->~RollingLatencyTracker();
new (this) RollingLatencyTracker(std::move(rhs));
}
return *this;
}

private:
RollingStats* stats_{nullptr};
std::chrono::time_point<std::chrono::steady_clock> begin_;
};
} // namespace util
} // namespace cachelib
} // namespace facebook