未验证 提交 20471de7 编写于 作者: L liutiexing 提交者: GitHub

Fix host event recorder (#37944)

* add align for WorkQueue

* add spinlock

* merge develop

* merge

* Add EventsWaiter

* Revert "Add EventsWaiter"

This reverts commit e206173aa9be7401b83a53581627bfaf557c8fb2.

* Fix RecordEvent
Co-authored-by: Nliutiexing <liutiexing@google.com>
上级 5cecfd23
......@@ -353,7 +353,7 @@ RecordEvent::RecordEvent(const char *name, const EventRole role) {
#endif
#endif
if (UNLIKELY(g_enable_host_event_recorder_hook == false)) {
RecordEvent(name, role, "none");
OriginalConstruct(name, role, "none");
return;
}
shallow_copy_name_ = name;
......@@ -371,7 +371,7 @@ RecordEvent::RecordEvent(const std::string &name, const EventRole role) {
#endif
#endif
if (UNLIKELY(g_enable_host_event_recorder_hook == false)) {
RecordEvent(name, role, "none");
OriginalConstruct(name, role, "none");
return;
}
name_ = new std::string(name);
......@@ -389,13 +389,18 @@ RecordEvent::RecordEvent(const std::string &name, const EventRole role,
}
#endif
#endif
if (g_enable_host_event_recorder_hook) {
if (UNLIKELY(g_enable_host_event_recorder_hook == false)) {
OriginalConstruct(name, role, attr);
return;
}
name_ = new std::string(name);
start_ns_ = PosixInNsec();
attr_ = new std::string(attr);
return;
}
}
void RecordEvent::OriginalConstruct(const std::string &name,
const EventRole role,
const std::string &attr) {
if (g_state == ProfilerState::kDisabled || name.empty()) return;
// do some initialization
......@@ -408,7 +413,7 @@ RecordEvent::RecordEvent(const std::string &name, const EventRole role,
// Maybe need the same push/pop behavior.
Event *e = PushEvent(name, role, attr);
SetCurAnnotation(e);
// name_ = e->name();
*name_ = e->name();
}
RecordEvent::~RecordEvent() {
......@@ -431,10 +436,10 @@ RecordEvent::~RecordEvent() {
} else {
HostEventRecorder::GetInstance().RecordEvent(*name_, start_ns_, end_ns,
role_, *attr_);
}
delete attr_;
}
delete name_;
delete attr_;
}
return;
}
......
......@@ -139,17 +139,20 @@ struct RecordEvent {
~RecordEvent();
void OriginalConstruct(const std::string& name, const EventRole role,
const std::string& attr);
bool is_enabled_{false};
bool is_pushed_{false};
// Event name
const std::string* name_{nullptr};
std::string* name_{nullptr};
const char* shallow_copy_name_{nullptr};
uint64_t start_ns_;
// Need to distinguish name by op type, block_id, program_id and perhaps
// different kernel invocations within an op.
// std::string full_name_;
EventRole role_{EventRole::kOrdinary};
const std::string* attr_{nullptr};
std::string* attr_{nullptr};
};
/*class RecordRPCEvent {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册