提交 5acd34a2 编写于 作者: Z zaxon 提交者: Jiangtao Hu

framework: put perf conf into setup.bash && add compile opt for performance issue (#2315)

上级 206f515e
......@@ -31,8 +31,3 @@ scheduler_conf {
routine_num: 100
default_proc_num: 16
}
perf_conf {
enable: false
type: ALL
}
......@@ -17,7 +17,6 @@ cc_library(
"//cyber/common:global_data",
"//cyber/common:log",
"//cyber/common:macros",
"//cyber/proto:perf_conf_cc_proto",
"//cyber/time:time",
]
)
......
......@@ -18,7 +18,8 @@
#include <string>
#include "cyber/common/global_data.h"
#include "cyber/base/macros.h"
#include "cyber/common/environment.h"
#include "cyber/common/log.h"
#include "cyber/common/macros.h"
#include "cyber/state.h"
......@@ -28,18 +29,22 @@ namespace apollo {
namespace cyber {
namespace event {
using common::GlobalData;
using proto::PerfConf;
using proto::PerfType;
using common::GetEnv;
PerfEventCache::PerfEventCache() {
auto& global_conf = GlobalData::Instance()->Config();
if (global_conf.has_perf_conf()) {
perf_conf_.CopyFrom(global_conf.perf_conf());
enable_ = perf_conf_.enable();
auto trans_perf = GetEnv("cyber_trans_perf");
if (trans_perf != "" &&
std::stoi(trans_perf)) {
enable_trans_perf_ = true;
}
auto sched_perf = GetEnv("cyber_sched_perf");
if (sched_perf != "" &&
std::stoi(sched_perf)) {
enable_sched_perf_ = true;
}
if (enable_) {
if (enable_sched_perf_ ||
enable_trans_perf_) {
if (!event_queue_.Init(kEventQueueSize)) {
AERROR << "Event queue init failed.";
throw std::runtime_error("Event queue init failed.");
......@@ -49,11 +54,15 @@ PerfEventCache::PerfEventCache() {
}
PerfEventCache::~PerfEventCache() {
if (!enable_) {
if (!enable_sched_perf_ &&
!enable_trans_perf_) {
return;
}
if (shutdown_.exchange(true)) {
return;
}
shutdown_ = true;
event_queue_.BreakAllWait();
if (io_thread_.joinable()) {
io_thread_.join();
......@@ -67,12 +76,7 @@ PerfEventCache::~PerfEventCache() {
void PerfEventCache::AddSchedEvent(const SchedPerf event_id,
const uint64_t cr_id, const int proc_id,
const int cr_state) {
if (!enable_) {
return;
}
if (perf_conf_.type() != PerfType::SCHED &&
perf_conf_.type() != PerfType::ALL) {
if (likely(!enable_sched_perf_)) {
return;
}
......@@ -89,12 +93,7 @@ void PerfEventCache::AddSchedEvent(const SchedPerf event_id,
void PerfEventCache::AddTransportEvent(const TransPerf event_id,
const uint64_t channel_id,
const uint64_t msg_seq) {
if (likely(!enable_)) {
return;
}
if (unlikely(perf_conf_.type() != PerfType::TRANSPORT &&
perf_conf_.type() != PerfType::ALL)) {
if (likely(!enable_trans_perf_)) {
return;
}
......
......@@ -25,7 +25,6 @@
#include "cyber/base/bounded_queue.h"
#include "cyber/common/macros.h"
#include "cyber/event/perf_event.h"
#include "cyber/proto/perf_conf.pb.h"
namespace apollo {
namespace cyber {
......@@ -48,10 +47,10 @@ class PerfEventCache {
std::thread io_thread_;
std::ofstream of_;
bool enable_ = false;
bool shutdown_ = false;
bool enable_trans_perf_ = false;
bool enable_sched_perf_ = false;
std::atomic<bool> shutdown_ = {false};
proto::PerfConf perf_conf_;
base::BoundedQueue<EventBasePtr> event_queue_;
const int kFlushSize = 512;
......
......@@ -18,7 +18,6 @@ proto_library(
":choreography_conf_proto",
":scheduler_conf_proto",
":transport_conf_proto",
":perf_conf_proto",
":run_mode_conf_proto",
":topology_conf_proto",
],
......@@ -84,20 +83,6 @@ proto_library(
],
)
cc_proto_library(
name = "perf_conf_cc_proto",
deps = [
":perf_conf_proto",
],
)
proto_library(
name = "perf_conf_proto",
srcs = [
"perf_conf.proto",
],
)
cc_proto_library(
name = "run_mode_conf_cc_proto",
deps = [
......
......@@ -4,14 +4,12 @@ package apollo.cyber.proto;
import "cyber/proto/scheduler_conf.proto";
import "cyber/proto/transport_conf.proto";
import "cyber/proto/perf_conf.proto";
import "cyber/proto/run_mode_conf.proto";
import "cyber/proto/topology_conf.proto";
message CyberConfig {
optional SchedulerConf scheduler_conf = 1;
optional TransportConf transport_conf = 2;
optional PerfConf perf_conf = 3;
optional RunModeConf run_mode_conf = 4;
optional TopologyConf topology_conf = 5;
optional RunModeConf run_mode_conf = 3;
optional TopologyConf topology_conf = 4;
}
syntax = "proto2";
package apollo.cyber.proto;
enum PerfType {
SCHED = 1;
TRANSPORT = 2;
DATA_CACHE = 3;
ALL = 4;
}
message PerfConf {
optional bool enable = 1 [default = false];
optional PerfType type = 2 [default = ALL];
}
......@@ -9,6 +9,7 @@ PYTHON_LD_PATH="/apollo/bazel-bin/cyber/py_wrapper"
launch_path="${CYBER_PATH}/tools/cyber_launch"
qt_path=/usr/local/Qt5.5.1/5.5/gcc_64
export LD_LIBRARY_PATH=${qt_path}/lib:$LD_LIBRARY_PATH
export QT_QPA_PLATFORM_PLUGIN_PATH=${qt_path}/plugins
export PATH=${binary_path}:${recorder_path}:${monitor_path}:${launch_path}:${qt_path}/bin:${visualizer_path}:$PATH
......@@ -22,6 +23,9 @@ export GLOG_alsologtostderr=0
export GLOG_colorlogtostderr=1
export GLOG_minloglevel=0
export cyber_trans_perf=0
export cyber_sched_perf=0
# for DEBUG log
#export GLOG_minloglevel=-1
#export GLOG_v=4
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册