提交 b3f358f4 编写于 作者: L Li Xinqi 提交者: Jinhui Yuan

Bugfix reduce actor act cnt (#1013)

* bugfix: fix node2component_id bug according to new depth definition

* only take account of ActNode with output


Former-commit-id: 4a0f6219
上级 d165da8a
......@@ -445,15 +445,6 @@ ActGraph::ActGraph(const Plan& plan, std::unique_ptr<std::list<ActEvent>>&& act_
InitEdges();
InitDepth();
InitTaskId2TaskProto();
InitActorStatistics();
}
void ActGraph::InitActorStatistics() {
for (const ActEvent& act_event : *act_events_) {
int64_t actor_id = act_event.actor_id();
++actor_id2act_cnt_[actor_id];
actor_id2total_act_time_[actor_id] += Duration4ActEvent(act_event);
}
}
void ActGraph::ForEachDepthRangeRegstUids(
......
......@@ -73,10 +73,6 @@ class ActGraph final : public Graph<ActNode, ActEdge> {
const TaskProto& GetTaskProto(int64_t actor_id) const {
return *task_id2task_proto_.at(actor_id);
}
const HashMap<int64_t, int64_t>& actor_id2act_cnt() const { return actor_id2act_cnt_; }
const HashMap<int64_t, double>& actor_id2total_act_time() const {
return actor_id2total_act_time_;
}
const std::list<const ActNode*>& Nodes4Depth(int64_t depth) const {
return depth2nodes_.at(depth);
}
......@@ -94,7 +90,6 @@ class ActGraph final : public Graph<ActNode, ActEdge> {
void InitEdges();
void InitDepth();
void InitTaskId2TaskProto();
void InitActorStatistics();
void ForEachDepthRangeRegstUids(
const std::function<void(const Range& range, const std::list<std::string>& regst_uids)>&
Handler) const;
......@@ -110,8 +105,6 @@ class ActGraph final : public Graph<ActNode, ActEdge> {
HashMap<std::string, ActNode*> regst_uid2producer_node_;
HashMap<std::string, std::list<const ActNode*>> regst_uid2consumer_nodes_;
HashMap<int64_t, std::list<const ActNode*>> depth2nodes_;
HashMap<int64_t, int64_t> actor_id2act_cnt_;
HashMap<int64_t, double> actor_id2total_act_time_;
};
} // namespace oneflow
......
......@@ -230,20 +230,27 @@ double FormalDuration4ExperimentalDuration(TaskType task_type, double duration,
double CalcBaseII(const ActGraph& act_graph) {
int64_t max_act_cnt = 0;
for (const auto& pair : act_graph.actor_id2act_cnt()) {
if (max_act_cnt < pair.second) { max_act_cnt = pair.second; }
}
HashMap<int64_t, int64_t> actor_id2outputed_act_cnt;
act_graph.ForEachNode([&](const ActNode* act_node) {
int64_t actor_id = act_node->actor_id();
if (!act_node->out_edges().empty()) {
++actor_id2outputed_act_cnt[actor_id];
max_act_cnt = std::max(max_act_cnt, actor_id2outputed_act_cnt[actor_id]);
}
});
HashMap<int64_t, double> actor_id2act_frequency;
for (const auto& pair : act_graph.actor_id2act_cnt()) {
for (const auto& pair : actor_id2outputed_act_cnt) {
actor_id2act_frequency[pair.first] = 1.0 * pair.second / max_act_cnt;
}
HashMap<int64_t, double> stream_id2total_calc_time;
act_graph.ForEachNode([&](const ActNode* act_node) {
int64_t stream_id = act_node->act_event().work_stream_id();
int64_t actor_id = act_node->actor_id();
auto frequence_it = actor_id2act_frequency.find(actor_id);
if (frequence_it == actor_id2act_frequency.end()) { return; }
int64_t stream_id = act_node->act_event().work_stream_id();
TaskType task_type = act_graph.GetTaskProto(actor_id).task_type();
stream_id2total_calc_time[stream_id] += FormalDuration4ExperimentalDuration(
task_type, act_node->Duration(), actor_id2act_frequency.at(actor_id));
stream_id2total_calc_time[stream_id] +=
FormalDuration4ExperimentalDuration(task_type, act_node->Duration(), frequence_it->second);
});
double base_ii = 0;
for (const auto& pair : stream_id2total_calc_time) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册