已合并
【msServiceProfiler】【parse】【微重构】 增强detokenize事件的处理逻辑 #173
Masaka创建于 3月6日
【msServiceProfiler】【parse】【微重构】 增强detokenize事件的处理逻辑 #173
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Masaka 的贡献)ascend-robot
3月6日 评论:
3月6日 评论:
3月6日 添加了label:stat/needs-squash
ascend-robot
3月6日 评论:
3月6日 评论:
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/msserviceprofiler | ✅ ChenHuiwen, mjsz11 (2/2) | ✅ mjsz11 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


3月6日 添加了label:ascend-cla/no
此处折叠了5条事件消息 查看更多
3月6日 修改了pull request 的描述
Masaka
3月6日 评论:
3月6日 评论:
compile


3月6日 添加了label:ci-pipeline-running
3月6日 删除了label:ci-pipeline-running
3月6日 添加了label:ci-pipeline-failed
ascend-robot
3月6日 评论:
3月6日 评论:
流水线 PR-pipeline_msserviceprofiler#501 运行失败
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_msserviceprofiler_arm | ✅ | >>> |
| Build_msserviceprofiler_x86 | ✅ | >>> | |
| 恶意代码检查 | Antipoison_msserviceprofiler | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck_msserviceprofiler | ✅ | >>> |
| 开源片段检查 | SCA_msserviceprofiler | ✅ | >>> |
| 开发者测试 | UT_msserviceprofiler | ✅ | >>> |
| PreSmoke_msserviceprofiler | ❌ | >>> | |
| 流水线 | PR-pipeline_msserviceprofiler | ❌ | >>> |


Masaka
3月7日 评论:
3月7日 评论:
compile


3月7日 删除了label:ci-pipeline-failed
3月7日 添加了label:ci-pipeline-running
3月7日 删除了label:ci-pipeline-running
3月7日 添加了label:ci-pipeline-failed
ascend-robot
3月7日 评论:
3月7日 评论:
流水线 PR-pipeline_msserviceprofiler#502 运行失败
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_msserviceprofiler_arm | ✅ | >>> |
| Build_msserviceprofiler_x86 | ✅ | >>> | |
| 恶意代码检查 | Antipoison_msserviceprofiler | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck_msserviceprofiler | ✅ | >>> |
| 开源片段检查 | SCA_msserviceprofiler | ✅ | >>> |
| 开发者测试 | UT_msserviceprofiler | ✅ | >>> |
| PreSmoke_msserviceprofiler | ❌ | >>> | |
| 流水线 | PR-pipeline_msserviceprofiler | ❌ | >>> |


3月7日 删除了label:ci-pipeline-failed
3月7日 添加了label:ci-pipeline-running
3月7日 删除了label:ci-pipeline-running
3月7日 添加了label:ci-pipeline-passed
ascend-robot
3月7日 评论:
3月7日 评论:
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_msserviceprofiler_arm | ✅ | >>> |
| Build_msserviceprofiler_x86 | ✅ | >>> | |
| 恶意代码检查 | Antipoison_msserviceprofiler | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck_msserviceprofiler | ✅ | >>> |
| 开源片段检查 | SCA_msserviceprofiler | ✅ | >>> |
| 开发者测试 | UT_msserviceprofiler | ✅ | >>> |
| PreSmoke_msserviceprofiler | ✅ | >>> | |
| 流水线 | PR-pipeline_msserviceprofiler | ✅ | >>> |


3月7日 删除了label:ci-pipeline-passed
ascend-robot
3月7日 评论:
3月7日 评论:
ascend-robot
3月7日 评论:
3月7日 评论:
Masaka
3月7日 评论:
3月7日 评论:
compile


3月7日 添加了label:ci-pipeline-running
3月7日 删除了label:ci-pipeline-running
3月7日 添加了label:ci-pipeline-passed
ascend-robot
3月7日 评论:
3月7日 评论:
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_msserviceprofiler_arm | ✅ | >>> |
| Build_msserviceprofiler_x86 | ✅ | >>> | |
| 恶意代码检查 | Antipoison_msserviceprofiler | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck_msserviceprofiler | ✅ | >>> |
| 开源片段检查 | SCA_msserviceprofiler | ✅ | >>> |
| 开发者测试 | UT_msserviceprofiler | ✅ | >>> |
| PreSmoke_msserviceprofiler | ✅ | >>> | |
| 流水线 | PR-pipeline_msserviceprofiler | ✅ | >>> |


ms_service_profiler/exporters/exporter_trace.py
@@ -404,4 +465,3 @@
404465 return flow_trace_events
405466
406467
【review】【逻辑】
这段代码对 detokenize 事件的处理逻辑做了重构,通过 _find_detokenize_predecessor 函数优先选择非 batchFrameworkProcessing 的事件作为前驱,设计思路是清晰的。不过在第 407 行 fallback 取时间最近事件作为前驱的这个分支,根据业务逻辑应该极少被触发,建议增加一条日志记录来便于后续排查确认该分支是否被触发。可参考改进代码:
# 在 return events_before_detokenize[-1] 之前加
logging.debug("No non-batchFrameworkProcessing event found, using last event as predecessor")


ms_service_profiler/exporters/exporter_trace.py
@@ -440,4 +500,4 @@
440500 trace_events.extend(queue_trace_events)
441501
442502 pull_kvcache_events = add_pull_kvcache_events(all_data_df[all_data_df['domain'] == 'PullKVCache'])
443503 trace_events.extend(pull_kvcache_events)
【review】【性能】
使用列表推导式构建 detokenize_indices 的写法比较简洁,但在循环体内每次迭代都调用 e.get('name'),在事件数量较大的场景下会有轻微的重复调用开销。可参考改进代码:
enriched = [(i, e, e.get('name')) for i, e in enumerate(events_ordered)]
detokenize_indices = [i for i, e, name in enriched if name == DETOKENIZE_NAME]


3月8日 解决了最后一个问题
ChenHuiwen
3月9日 评论:
3月9日 评论:
/lgtm


mjsz
3月9日 评论:
3月9日 评论:
/approve


3月9日 添加了label:approvedlgtm
ascend-robot
3月9日 评论:
3月9日 评论:
Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: mjsz11.
Reviewers who wrote a comment of /lgtm are: mjsz11, ChenHuiwen.


3月9日 合入了pull request
1. 修改描述
修改原因:
对每个 rid,把所有带该 rid 的事件按时间顺序排成一条 flow,第一个事件标为 flow 起点(
ph='s'),最后一个标为终点(ph='f'),中间为ph='t'。即严格按时间相邻关系连线。若时间序是 modelExec → batchFrameworkProcessing → detokenize,则图上会显示为一条链:modelExec → batchFrameworkProcessing → detokenize。detokenize 在 Engine 侧是异步执行的,与 batchFrameworkProcessing 是并行关系,而非串行。修改内容:
更新了从去detokenize事件生成分支链的逻辑,确保每个detokenize事件都能创建独立的分支,避免将先前的detokenize事件包含在同一分支中。此项改进通过为每个detokenize事件维持异步连接,提升了追踪图的清晰度。
2. 功能验证
3. 代码检视
4. 安全自检
典型安全编码问题
5. 变更知会
6. 冒烟修改