Changed MDP3 producer to honor new thread configuration.

This commit is contained in:
Pedro Pinto committed 2018-10-03 15:45:29 +00:00
1 parent 0833dce43d
commit ae3e721f62
6 files changed
+62 -25

No files matched your search

+18
View File
@@ -1,3 +1,21 @@
OrdermanCfg {
rule: "DeploymentType.type == 'dev'"
value {
executor {
thread_name: "oman_orders"
poll: false
hosted_actor: "MDSource"
hosted_actor: "OrderManager"
hosted_actor: "ExecutionGateway"
}
executor {
thread_name: "oman_slow"
poll: false
hosted_actor: "*"
}
}
}
OrdermanCfg {
value {
executor {
+3 -2
View File
@@ -1,6 +1,7 @@
Threads {
value {
thread_group {name_rx: "oman_orders" core: 0}
thread_group {name_rx: ".*" exclude:true core:0}
thread_group {name_rx: "mdp3feed" core: 0}
thread_group {name_rx: "oman_orders" core: 1}
thread_group {name_rx: ".*" exclude:true core:0 core:1}
}
}
+1 -1
View File
@@ -75,7 +75,7 @@ message CMEOptions
// Defines amount of time Feed Engine keeps cycling before going to sleep when no useful activity can be done
optional uint32 spin_time = 4 [default = 1];
optional uint32 channels_per_thread = 5 [default = 3];
repeated uint32 affinity = 10;
optional string thread_group = 10 [default=""]; // if present this will be used to retrieve affinity settings from Threads config key
optional uint32 udp_socket_buffer_size = 11 [default = 33554432]; //32mb
}
enum BookType {
+34 -20
View File
@@ -24,6 +24,23 @@ config::ThreadGroupCfg get_thread_cfg(std::string const &name) {
fmt::format("No configuration found for thread {}", name));
}
std::vector<uint32_t> get_affinity(std::string const &name) {
std::vector<uint32_t> result;
#ifndef WIN32
auto cfg = get_thread_cfg(name);
if (cfg.exclude()) {
auto total_cpus = sysconf(_SC_NPROCESSORS_ONLN);
for (int i = 0; i < total_cpus; i++)
if (std::find(cfg.core().begin(), cfg.core().end(), i) == cfg.core().end())
result.push_back(i);
} else {
for (auto const &core : cfg.core())
result.push_back(core);
}
#endif
return result;
}
#ifndef WIN32
void configure_thread(std::string const &name,
config::ThreadGroupCfg const &cfg, pthread_t t) {
@@ -54,46 +71,43 @@ void configure_thread(std::string const &name,
#endif
void configure_current_thread(std::string const &name) {
#ifndef WIN32
#ifndef WIN32
configure_thread(name, get_thread_cfg(name), pthread_self());
#endif
#endif
os::set_thread_name(name);
}
void configure_current_thread(std::string const &name,
config::ThreadGroupCfg const &cfg) {
#ifndef WIN32
#ifndef WIN32
configure_thread(name, cfg, pthread_self());
#endif
#endif
os::set_thread_name(name);
}
std::thread make_thread_from_function(std::string const &name,
std::function<void()> const &c) {
auto result = std::thread(
[c,name] () {
os::set_thread_name(name);
c();
});
#ifndef WIN32
auto result = std::thread([c, name]() {
os::set_thread_name(name);
c();
});
#ifndef WIN32
configure_thread(name, get_thread_cfg(name), result.native_handle());
#endif
#endif
return result;
}
std::thread make_thread_from_function(std::string const &name,
std::function<void()> const &c,
config::ThreadGroupCfg const &cfg) {
auto result = std::thread(
[c,name] () {
os::set_thread_name(name);
c();
});
#ifndef WIN32
auto result = std::thread([c, name]() {
os::set_thread_name(name);
c();
});
#ifndef WIN32
configure_thread(name, cfg, result.native_handle());
#endif
#endif
return result;
}
+2
View File
@@ -27,4 +27,6 @@ void configure_current_thread(std::string const&name, config::ThreadGroupCfg con
config::ThreadGroupCfg get_thread_cfg(std::string const &);
std::vector<uint32_t> get_affinity(std::string const&name);
}}
@@ -11,6 +11,8 @@
#include "lib/config/protos/MarketData.pb.h"
#include "lib/config/protos/system.pb.h"
#include "lib/utils/thread_manager.h"
#include <memory>
#include <boost/filesystem.hpp>
@@ -62,8 +64,8 @@ const onixs::FeedEngineSettings feed_engine_settings_from_config(const CMEOption
result.socketBufferSize(settings.udp_socket_buffer_size());
for (auto& core : settings.affinity()) {
auto affinity = threading::get_affinity("mdp3feed");
for (auto& core : affinity) {
result.threadAffinity().cpus().insert(core);
}