Skip to content

Async eviction #16

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 5 additions & 7 deletions .github/workflows/build-cachelib-centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ jobs:
name: "CentOS/latest - Build CacheLib with all dependencies"
runs-on: ubuntu-latest
# Docker container image name
container: "centos:latest"
container: "ghcr.io/igchor/cachelib-deps:centos8"
steps:
- name: "update packages"
run: dnf upgrade -y
- name: "install sudo,git"
run: dnf install -y sudo git cmake gcc
- name: "System Information"
run: |
echo === uname ===
Expand All @@ -32,8 +28,10 @@ jobs:
gcc -v
- name: "checkout sources"
uses: actions/checkout@v2
- name: "print workspace"
run: echo $GITHUB_WORKSPACE
- name: "build CacheLib using build script"
run: ./contrib/build.sh -j -v -T
run: mkdir build && cd build && cmake ../cachelib -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=/opt -DCMAKE_BUILD_TYPE=Debug && make install -j$(nproc)
- name: "run tests"
timeout-minutes: 60
run: cd opt/cachelib/tests && ../../../run_tests.sh
run: cd /opt/tests && $GITHUB_WORKSPACE/run_tests.sh
4 changes: 2 additions & 2 deletions .github/workflows/build-cachelib-debian.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: build-cachelib-debian-10
on:
push:
pull_request:
schedule:
- cron: '30 5 * * 0,3'

jobs:
build-cachelib-debian-10:
Expand Down
6 changes: 6 additions & 0 deletions cachelib/allocator/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
namespace facebook {
namespace cachelib {

CacheBase::CacheBase(unsigned numTiers): numTiers_(numTiers) {}

unsigned CacheBase::getNumTiers() const {
return numTiers_;
}

void CacheBase::setRebalanceStrategy(
PoolId pid, std::shared_ptr<RebalanceStrategy> strategy) {
std::unique_lock<std::mutex> l(lock_);
Expand Down
9 changes: 8 additions & 1 deletion cachelib/allocator/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum class RemoveContext { kEviction, kNormal };
// A base class of cache exposing members and status agnostic of template type.
class CacheBase {
public:
CacheBase() = default;
CacheBase(unsigned numTiers = 1);
virtual ~CacheBase() = default;

// Movable but not copyable
Expand All @@ -65,6 +65,9 @@ class CacheBase {
CacheBase(CacheBase&&) = default;
CacheBase& operator=(CacheBase&&) = default;

// TODO: come up with some reasonable number
static constexpr unsigned kMaxTiers = 8;

// Get a string referring to the cache name for this cache
virtual const std::string getCacheName() const = 0;

Expand Down Expand Up @@ -253,6 +256,10 @@ class CacheBase {
// @return The number of slabs that were actually reclaimed (<= numSlabs)
virtual unsigned int reclaimSlabs(PoolId id, size_t numSlabs) = 0;

unsigned getNumTiers() const;

unsigned numTiers_ = 1;

// Protect 'poolRebalanceStragtegies_' and `poolResizeStrategies_`
// and `poolOptimizeStrategy_`
mutable std::mutex lock_;
Expand Down
Loading