已合并
mstx data support combine multi data of same mark_id #346
mei-feiyao创建于 7月8日
mstx data support combine multi data of same mark_id #346
已合并
mei-feiyao创建于 7月8日
mei-feiyao
mei-feiyao成员
7月8日

PR 合入模板

注:经过自检不涉及的可标注“不涉及”或直接打勾,特殊情况请文字备注。不符合规范的 PR 不允许合入,请(后备)commit 注意。


1. 修改描述

  • 修改原因:
    mstx打点用例报错,原因在于模型打点数据超过156字节,mstx模块校验报错
  • 修改内容:
    落盘阶段发现数据超过156字节,拆分成多条;解析阶段发现同一mark id的数据存在多条,按照设置的数据块序号拼接打点数据

2. 功能验证


3. 分支合并要求


3. 代码检视

  • 要求:

    • 合入代码超过 200 行,需三人以上会议检视。
    • 检视密度≥1个/100行。
    • 检视缺陷密度未达要求需提供说明。
    • 大于 1000 行代码原则上不允许合入,需进行备案。
  • 检视意见数:____ 条 (请填写本次检视的意见总数,用于commit合入前审视)


4. 安全自检

Python、C++

C++


5. 变更知会


likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 mei-feiyao 的贡献)
atomgit-bot
atomgit-bot
7月8日 评论:

变更摘要

此 PR 主要解决 MSTX 打点数据超过 156 字节时模块校验报错的问题。落盘阶段会将超长数据拆分为多条片段(每条带有相同的 mark_id 和不同的 seg_idx),解析阶段则需要识别同一 mark_id 的多条数据,按 seg_idx 排序后拼接还原完整消息。核心改动涉及解析器内部数据结构从列表改为字典分组、save() 阶段增加合并逻辑,以及解码器新增 seg_idx 字段支持。

主要改动

  • MsprofTxParser 内部数据结构变更_msproftx_ex_datalist 改为 dict_msproftx_ex_data_dict),key 为 mark_id,value 为该 mark_id 对应的数据对象列表,用于支持同 mark_id 多片段的分组存储
  • _parse_data()mark_id 分组收集:在 TX_EX_INFO_TYPE 分支中,不再直接将数据追加到扁平列表,而是按 data_object.mark_id 分组存入 _msproftx_ex_data_dict
  • save() 增加多片段合并逻辑:遍历 _msproftx_ex_data_dict,对每个 mark_id 的片段按 seg_idx 排序、校验片段是否连续(缺失时输出 warning)、拼接所有片段的 message 字段为 full_msg,再写入数据库
  • MsprofTxDecoder 新增 seg_idx 属性:在 __init__ 中从 filed[7] 读取 _seg_idx,并暴露为只读属性,同时移除未使用的 Constant 导入
  • 单元测试适配新结构:测试用例中的断言从 _msproftx_ex_data 更新为 _msproftx_ex_data_dict,合并了重复的 test_save_with_msproftx_data 方法,并在 test_parse_should_run_success_when_open_file_success 中统一验证解析与保存流程
likedislike
atomgit-bot
atomgit-bot
7月8日 评论:

代码审查

审查总结

按优先级统计:

  • P2:2 个问题
    • 测试中 save() 未 mock DB 依赖,测试脆弱
    • 缺少多分段消息拼接的核心功能测试覆盖
  • P3:3 个问题
    • check.save() 被连续调用了两次,疑似遗留调试代码
    • hash_data_msproftx_ex_data_dict 为空时仍被计算(可选优化)
    • 未检测同一 mark_id 下的重复 seg_idx

已审查文件

文件 结果
analysis/msparser/msproftx/msproftx_parser.py 发现 2 个 P3 问题
analysis/profiling_bean/struct_info/msproftx_decoder.py 无问题
test/msprof_python/ut/testcase/msparser/msproftx/test_msproftx_parser.py 发现 2 个 P2 + 1 个 P3 问题

总体风险评估中等。核心逻辑(按 seg_idx 排序拼接多分段消息)正确,seg_idx 字段的 struct 布局与 decoder 一致。主要风险集中在测试层面——核心功能缺少多分段场景的测试覆盖,且测试对 DB 层的隔离被移除,降低了测试的健壮性。建议在合入前补充多分段数据的测试用例并恢复 DB mock。

类型 数量
🔴 阻塞 0
🟡 建议 2

💬 仅评论

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
7月8日 评论:

CLA Signature Pass

mei-feiyao, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robot
ascend-robot成员
7月8日 评论:

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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-Ascend/msprof 陈豪, Seanesmhxocism (2/2) 陈豪 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
mei-feiyao
mei-feiyao成员
7月8日 评论:

compile

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
7月8日 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
7月8日 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
7月8日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
7月8日 添加了label:docs-ci-pipeline-success
ascend-robot
ascend-robot成员
7月8日 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
7月8日 删除了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7月8日 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
7月8日 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
7月8日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
7月8日 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7月8日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月8日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月8日 评论:
流水线 PR-pipeline_msprof#1184 [ commitID:25d02c1a ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 Build_msprof_arm >>>
Build_msprof_x86 >>>
恶意代码检查 Antipoison_msprof >>>
编码安全与规范检查 CodeCheck_msprof >>>
PreCommit_gitcode >>>
开源片段检查 SCA_msprof >>>
开发者测试 UT_msprof >>>
PreSmoke_msprof >>>
流水线 PR-pipeline_msprof >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
atomgit-bot
atomgit-bot7月8日进行代码检视1
test/msprof_python/ut/testcase/msparser/msproftx/test_msproftx_parser.py
@@ -71,7 +71,7 @@
7171 with FdOpen(os.path.join(cls.DATA_PATH, "aging.additional.msproftx.slice_0"), operate="wb") as f:
7272 for data in msproftx_data:
7373 bytes_data = struct.pack(StructFmt.MSPROFTX_FMT, *data)
7474 f.write(bytes_data)
atomgit-bot
atomgit-bot7月8日评论:

🟡 Medium Priority

本 PR 的核心功能是:当打点数据超过 156 字节时拆分为多条(不同 seg_idx),解析阶段按 seg_idx 排序后拼接。但测试数据 make_msproftx_data(第 63-74 行)仅构造了 seg_idx=0 的单条消息(155 个 's'),未覆盖多分段拼接场景。这意味着 save() 中的排序逻辑(obj_list.sort(key=lambda x: x.seg_idx))、连续性校验(missing_segs)、以及消息拼接("".join(...))均无测试验证,PR 所述的核心功能缺乏测试看护。

建议:在 make_msproftx_data 中增加多分段测试数据(同一 mark_id、不同的 seg_idx),并在测试中验证拼接后的 full_msg 内容正确、missing_segs 告警逻辑在缺段时能触发。

likedislike
atomgit-bot
atomgit-bot7月8日进行代码检视1
test/msprof_python/ut/testcase/msparser/msproftx/test_msproftx_parser.py
@@ -108,4 +99,1 @@
108- InfoConfReader()._info_json = {"devices": '0'}
109- check = MsprofTxParser(self.file_list, self.CONFIG)
110- check._msproftx_ex_data = [123]
11199 check.save()
atomgit-bot
atomgit-bot7月8日评论:

🟡 Medium Priority

变更后的 test_parse_should_run_success_when_open_file_success(第 91-99 行)调用了 check.save(),但未 mock HashDictDataMsprofTxModelMsprofTxExModel。旧代码中原本有独立的 test_save_with_msproftx_data 测试方法,通过 mock MsprofTxModel.flushMsprofTxExModel.flush 来隔离 DB 操作。现在 save() 直接执行真实的 DB 写入逻辑,其行为依赖运行时文件系统状态(host/sqlite/ 目录是否存在、sqlite3 是否可用等),导致测试脆弱,可能因环境差异而失败。

建议:在 test_parse_should_run_success_when_open_file_success 中 mock HashDictDataMsprofTxModel.flushMsprofTxExModel.flush,保持测试对 DB 层的隔离。或者将 save 调用恢复为独立的、带 mock 的测试方法。

likedislike
mei-feiyaomei-feiyao成员
7月8日 解决了最后一个问题
wangzixuan成员
7月8日 评论:

/lgtm

likedislike
chenhao_1209成员
7月9日 评论:

/approve

likedislike
ascend-robotascend-robot成员
7月9日 添加了label:approvedlgtm
ascend-robotascend-robot成员
7月9日 合入了pull request
ascend-robot
ascend-robot成员
7月9日 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike