Skip to content

Commit e0b6fff

Browse files
committed
crimson: introduce crimson_seastar_num_threads
This new option is there to allow *basic* cluster deployments. crimson_seastar_num_threads can be used globally for all the OSDs in the cluster: ``` osd: crimson_seastar_num_threads: <n> crimson_alien_op_num_threads: <m> ``` As a result, all the available CPUs will be allocated to *both* seastar reactor threads and to Alienstore threads - without any exclusion. Notes: * The core allocation will most likely overlap between OSDS and/or Seastar and Alienstore. An optiomal deployment requires `crimson_alien_thread_cpu_cores` and `crimson_seastar_cpu_cores` to be set for each OSD based on the host its located at. * Seastar reactor number (smp::count) will be deduced directly from crimson_seastar_num_threads --- Documentation followup: ceph#57352 --- ### Option 1 (Optimal) * CPUs are pinned to the provided sets (seastar and alien cpu sets) * thread-affinity = 1 (seastar's default). * smp (smp::count / reactor count): `seastar_cpu_set.size()` * Seastar reactor threads: `seastar_cpu_set.size()` * Alienstore threads num: `crimson_alien_op_num_threads` --- ### Option 2 (Basic): * No CPU pinning. * thread-affinity = 0 * smp (smp::count / reactor count) = `crimson_seastar_num_threads` * Seastar reactor threads num: `crimson_seastar_num_threads` * Alienstore threads num: `crimson_alien_op_num_threads` --- Fixes: https://tracker.ceph.com/issues/65752 Signed-off-by: Matan Breizman <[email protected]>
1 parent e03f7be commit e0b6fff

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

src/common/options/crimson.yaml.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ options:
3131
desc: CPU cores on which alienstore threads will run in cpuset(7) format
3232
flags:
3333
- startup
34+
- name: crimson_seastar_num_threads
35+
type: uint
36+
level: advanced
37+
default: 0
38+
desc: The number of threads for serving seastar reactors without CPU pinning, overridden if crimson_seastar_cpu_cores is set
39+
flags:
40+
- startup
41+
min: 0
42+
max: 32
3443
- name: crimson_osd_stat_interval
3544
type: int
3645
level: advanced

src/crimson/os/alienstore/alien_store.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,23 @@ seastar::future<> AlienStore::start()
101101
if (!store) {
102102
ceph_abort_msgf("unsupported objectstore type: %s", type.c_str());
103103
}
104-
auto cpu_cores = seastar::resource::parse_cpuset(
105-
get_conf<std::string>("crimson_alien_thread_cpu_cores"));
106-
// crimson_alien_thread_cpu_cores are assigned to alien threads.
107-
if (!cpu_cores.has_value()) {
108-
// no core isolation by default, seastar_cpu_cores will be
109-
// shared between both alien and seastar reactor threads.
110-
cpu_cores = seastar::resource::parse_cpuset(
111-
get_conf<std::string>("crimson_seastar_cpu_cores"));
112-
ceph_assert(cpu_cores.has_value());
104+
/*
105+
* crimson_alien_thread_cpu_cores must be set for optimal performance.
106+
* Otherwise, no CPU pinning will take place.
107+
*/
108+
std::optional<seastar::resource::cpuset> alien_thread_cpu_cores;
109+
110+
if (std::string conf_cpu_cores =
111+
get_conf<std::string>("crimson_alien_thread_cpu_cores");
112+
!conf_cpu_cores.empty()) {
113+
logger().debug("{} using crimson_alien_thread_cpu_cores", __func__);
114+
alien_thread_cpu_cores =
115+
seastar::resource::parse_cpuset(conf_cpu_cores);
113116
}
117+
114118
const auto num_threads =
115119
get_conf<uint64_t>("crimson_alien_op_num_threads");
116-
tp = std::make_unique<crimson::os::ThreadPool>(num_threads, 128, cpu_cores);
120+
tp = std::make_unique<crimson::os::ThreadPool>(num_threads, 128, alien_thread_cpu_cores);
117121
return tp->start();
118122
}
119123

src/crimson/osd/main_config_bootstrap_helpers.cc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,32 @@ _get_early_config(int argc, const char *argv[])
150150
std::end(early_args),
151151
[](auto* arg) { return "--cpuset"sv == arg; });
152152
found == std::end(early_args)) {
153-
auto smp_config = crimson::common::get_conf<std::string>("crimson_seastar_cpu_cores");
154-
if (!smp_config.empty()) {
153+
auto cpu_cores = crimson::common::get_conf<std::string>("crimson_seastar_cpu_cores");
154+
if (!cpu_cores.empty()) {
155155
// Set --cpuset based on crimson_seastar_cpu_cores config option
156156
// --smp default is one per CPU
157157
ret.early_args.emplace_back("--cpuset");
158-
ret.early_args.emplace_back(smp_config);
159-
logger().info("get_early_config: set --cpuset {}", smp_config);
158+
ret.early_args.emplace_back(cpu_cores);
159+
ret.early_args.emplace_back("--thread-affinity");
160+
ret.early_args.emplace_back("1");
161+
logger().info("get_early_config: set --thread-affinity 1 --cpuset {}",
162+
cpu_cores);
160163
} else {
161-
logger().warn("get_early_config: no cpuset specified, falling back"
162-
" to seastar's default of: all");
164+
auto reactor_num = crimson::common::get_conf<uint64_t>("crimson_seastar_num_threads");
165+
if (!reactor_num) {
166+
logger().error("get_early_config: crimson_seastar_cpu_cores"
167+
" or crimson_seastar_num_threads"
168+
" must be set");
169+
ceph_abort();
170+
}
171+
std::string smp = fmt::format("{}", reactor_num);
172+
ret.early_args.emplace_back("--smp");
173+
ret.early_args.emplace_back(smp);
174+
ret.early_args.emplace_back("--thread-affinity");
175+
ret.early_args.emplace_back("0");
176+
logger().info("get_early_config: set --thread-affinity 0 --smp {}",
177+
smp);
178+
163179
}
164180
} else {
165181
logger().error("get_early_config: --cpuset can be "

0 commit comments

Comments
 (0)