Skip to content

Commit

Permalink
os/bluestore: make osd_memory_limit default to .8x the cgroup limit
Browse files Browse the repository at this point in the history
We do this at runtime in _set_cache_sizes so that changes to these values
at runtime will be picked up.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Mar 11, 2019
1 parent 4ddfe3a commit 5c6b533
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/common/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4013,6 +4013,13 @@ std::vector<Option> get_global_options() {
.add_see_also("bluestore_cache_autotune")
.set_description("When tcmalloc and cache autotuning is enabled, try to keep this many bytes mapped in memory."),

Option("osd_memory_target_cgroup_limit_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
.set_default(0.8)
.set_min_max(0.0, 1.0)
.add_see_also("osd_memory_target")
.set_description("Set the default value for osd_memory_target to the cgroup memory limit (if set) times this value")
.set_long_description("A value of 0 disables this feature."),

Option("osd_memory_base", Option::TYPE_SIZE, Option::LEVEL_DEV)
.set_default(768_M)
.add_see_also("bluestore_cache_autotune")
Expand Down
19 changes: 19 additions & 0 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "include/intarith.h"
#include "include/stringify.h"
#include "include/str_map.h"
#include "include/util.h"
#include "common/errno.h"
#include "common/safe_io.h"
#include "common/PriorityCache.h"
Expand Down Expand Up @@ -4029,6 +4030,7 @@ const char **BlueStore::get_tracked_conf_keys() const
"bluestore_max_blob_size_ssd",
"bluestore_max_blob_size_hdd",
"osd_memory_target",
"osd_memory_target_cgroup_limit_ratio",
"osd_memory_base",
"osd_memory_cache_min",
"bluestore_cache_autotune",
Expand Down Expand Up @@ -4200,6 +4202,23 @@ void BlueStore::_set_blob_size()

int BlueStore::_set_cache_sizes()
{
// set osd_memory_target *default* based on cgroup limit?
// (do this before we fetch the osd_memory_target value!)
double cgroup_ratio = cct->_conf.get_val<double>(
"osd_memory_target_cgroup_limit_ratio");
if (cgroup_ratio > 0.0) {
uint64_t cgroup_limit = 0;
if (get_cgroup_memory_limit(&cgroup_limit) == 0 &&
cgroup_limit) {
uint64_t def = cgroup_limit * cgroup_ratio;
dout(10) << __func__ << " osd_memory_target_cgroup_limit_ratio "
<< cgroup_ratio << ", cgroup_limit " << cgroup_limit
<< ", defaulting osd_memory_target to " << def
<< dendl;
cct->_conf.set_val_default("osd_memory_target", stringify(def));
}
}

ceph_assert(bdev);
cache_autotune = cct->_conf.get_val<bool>("bluestore_cache_autotune");
cache_autotune_interval =
Expand Down

0 comments on commit 5c6b533

Please sign in to comment.