Pull Request has been successfully merged by CANN-robot.
(Thank you for sunhaoxuan2024's contribution.)变更摘要
本 PR 针对泳道图生成工具 tools/profiling/draw_swim_lane.py 进行性能优化:通过引入更快的 JSON 解析与序列化方式、用哈希索引字典替代线性查找、为重复的算子信息查询增加缓存,并配合 gc.freeze() 等手段减少生成耗时,同时新增泳道图生成的开始/结束打印标识,便于观测生成流程。
主要改动
- JSON 解析加速: 在
load_json中优先尝试使用orjson(import orjson as _fast_json,导入失败则回退标准json),并在解析期间临时执行gc.disable()以提升大文件读取性能。 - JSON 输出压缩:
convert_to_chrome_trace_json将带缩进的json.dump(..., indent=4)改为json.dumps(..., separators=(",", ":"))后直接写入文件,去除多余空白以减小生成的 trace 文件体积。 - 哈希索引字典替代线性查找: 删除逐个遍历的
get_func_index,改为在load_dyn_topo中预先构建func_index_by_hash字典,将root_index、leaf_index的查询由线性扫描降为 O(1) 字典查找。 - 重复计算结果缓存: 在
load_dyn_topo中新增hash_order_info_cache、tensors_cache、rawtensors_cache,复用fcvt.get_hash_order_info_for_task、fcvt.get_tensors、fcvt.get_rawtensors的结果,避免同哈希任务的重复计算。 - GC 冻结与流程标识: 在
__main__读取函数表数据后调用gc.freeze()减少 GC 开销,并在生成前后打印Swimlane diagram generation start/end标识以标明生成起止。


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 |
|---|---|---|
| tools/profiling | ✅ 尹杰, congqiannan (2/2) | ✅ 尹杰 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
sunhaoxuan2024, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
wangzheng97


/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
wangzheng97


泳道图增加开始结束标识,并且优化泳道图生成性能