Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24065 from jdurgin/wip-luminous-cache-autotune
luminous: os/bluestore: cache autotuning and memory limit Reviewed-by: Sage Weil <sage@redhat.com>
- Loading branch information
Showing
17 changed files
with
2,235 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=8 sw=2 smarttab | ||
/* | ||
* Ceph - scalable distributed file system | ||
* | ||
* Copyright (C) 2018 Red Hat | ||
* | ||
* This is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1, as published by the Free Software | ||
* Foundation. See file COPYING. | ||
* | ||
*/ | ||
|
||
#include "PriorityCache.h" | ||
|
||
namespace PriorityCache { | ||
int64_t get_chunk(uint64_t usage, uint64_t chunk_bytes) { | ||
// Add a chunk of headroom and round up to the near chunk | ||
uint64_t val = usage + chunk_bytes; | ||
uint64_t r = (val) % chunk_bytes; | ||
if (r > 0) | ||
val = val + chunk_bytes - r; | ||
return val; | ||
} | ||
|
||
PriCache::~PriCache() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=8 sw=2 smarttab | ||
/* | ||
* Ceph - scalable distributed file system | ||
* | ||
* Copyright (C) 2018 Red Hat | ||
* | ||
* This is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1, as published by the Free Software | ||
* Foundation. See file COPYING. | ||
* | ||
*/ | ||
|
||
#ifndef CEPH_PRIORITY_CACHE_H | ||
#define CEPH_PRIORITY_CACHE_H | ||
|
||
#include <stdint.h> | ||
#include <string> | ||
|
||
namespace PriorityCache { | ||
enum Priority { | ||
PRI0, // Reserved for special items | ||
PRI1, // High priority cache items | ||
PRI2, // Medium priority cache items | ||
PRI3, // Low priority cache items | ||
LAST = PRI3, | ||
}; | ||
|
||
int64_t get_chunk(uint64_t usage, uint64_t chunk_bytes); | ||
|
||
struct PriCache { | ||
virtual ~PriCache(); | ||
|
||
/* Ask the cache to request memory for the given priority rounded up to | ||
* the nearst chunk_bytes. This for example, may return the size of all | ||
* items associated with this priority plus some additional space for | ||
* future growth. Note that the cache may ultimately be allocated less | ||
* memory than it requests here. | ||
*/ | ||
virtual int64_t request_cache_bytes(PriorityCache::Priority pri, uint64_t chunk_bytes) const = 0; | ||
|
||
// Get the number of bytes currently allocated to the given priority. | ||
virtual int64_t get_cache_bytes(PriorityCache::Priority pri) const = 0; | ||
|
||
// Get the number of bytes currently allocated to all priorities. | ||
virtual int64_t get_cache_bytes() const = 0; | ||
|
||
// Allocate bytes for a given priority. | ||
virtual void set_cache_bytes(PriorityCache::Priority pri, int64_t bytes) = 0; | ||
|
||
// Allocate additional bytes for a given priority. | ||
virtual void add_cache_bytes(PriorityCache::Priority pri, int64_t bytes) = 0; | ||
|
||
// Commit the current number of bytes allocated to the cache. | ||
virtual int64_t commit_cache_size() = 0; | ||
|
||
// Get the ratio of available memory this cache should target. | ||
virtual double get_cache_ratio() const = 0; | ||
|
||
// Set the ratio of available memory this cache should target. | ||
virtual void set_cache_ratio(double ratio) = 0; | ||
|
||
// Get the name of this cache. | ||
virtual std::string get_cache_name() const = 0; | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.