Pull Request已成功合入, 合并人@CANN-robot
(感谢 tangqunzhang 的贡献)变更摘要
本 PR 主要聚焦于 compiler/graph/build/memory/ 目录下 stream 间内存复用相关代码的性能优化,属于不改变功能行为的重构。具体通过消除 map 值深拷贝、将循环内冗余调用上提、以及直接传入已查找的集合引用三类手段减少冗余计算与内存拷贝,涉及 block_mem_zero_copy.cc、block_mem_assigner.cc 及 block_mem_assigner.h。
主要改动
-
避免 map 深拷贝:在
block_mem_zero_copy.cc的SetReleaseBlockLifeEnd中,将to_release->NodeTypeIndexList().back().out_stream_life_time_的绑定方式由const auto改为const auto &,使每次调用不再产生整个out_stream_life_time_map 的堆分配与拷贝。 -
消除循环内冗余调用:在
block_mem_assigner.cc的GetDiffStreamEdgeLife中,将GetStreamId(node_desc)从 peer anchor 循环体内上提到循环外,使每个 peer anchor 少一次GetStreamId调用。 -
消除重复 map 查找:
block_mem_assigner.cc/h中InsertStreamInEdge的签名改为直接接收已查找的std::set<EdgeLife, CompareEdgeLife> &in_edge_set引用,调用方AddInStreamEdge及GetDiffStreamEdgeLife传入预先通过in_stream_edges_[dst_stream_id][src_stream_id]查得的集合,省去函数内部对in_stream_edges_的重复查找(每条跨流边少一次 O(log S) 查找)。


🤖 本次改动均为数据 / 生成 / 二进制文件(如测试用例、锁文件、媒体资源),没有可审查的代码逻辑,已跳过 AI 代码审查。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ge | ✅ Mexyy, kobemini, 张德鹏 (3/2) | ✅ 张德鹏 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
tangqunzhang, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/lgtm


Pull Request
描述
优化
compiler/graph/build/memory/下 stream 间内存复用相关代码的性能,减少冗余计算和内存拷贝。具体改动:
block_mem_zero_copy.cc:SetReleaseBlockLifeEnd中out_stream_life_time_的const auto改为const auto &,避免每次调用产生整个 map 的深拷贝block_mem_assigner.cc:GetDiffStreamEdgeLife中将GetStreamId(node_desc)提到循环外,避免在 peer anchor 循环内重复调用block_mem_assigner.cc/h:AddInStreamEdge中新增InsertStreamInEdge(set&, ...)重载,直接传入已查找的in_edge_set引用,消除InsertStreamInEdge内部的重复 map 查找变更类型
关联的Issue
无
如何测试
核对清单
其他信息
性能改进点:
SetReleaseBlockLifeEnd调用避免一次堆分配+拷贝GetStreamId每个 peer anchor 少一次调用AddInStreamEdge中每条跨流边少一次 O(log S) 查找