perf: skip disabled submission log formatting - #64
Merged
XiaoCow666 merged 1 commit intoSep 19, 2026
Merged
XiaoCow666 merged 1 commit into
XiaoCow666 merged 1 commit into
Conversation
XiaoCow666
approved these changes
Sep 19, 2026
XiaoCow666
left a comment
Owner
There was a problem hiding this comment.
CodeSense 自动评审
未发现会导致错误结果、回归或无法运行的阻塞问题;该变更在日志级别未启用时提前返回,能够避免不必要的格式化。
已有验证信息
- 事件仅提供了 tasks/submission_tasks.py 的 diff,未提供自动化检查或测试运行结果。
评审事件:47629600-b42c-11f1-9608-4f0a91c4dea6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更摘要
在
tasks/submission_tasks.py的提交评测日志辅助函数中,先检查目标日志级别是否启用;关闭时直接返回,避免无效的耗时计算、字段拼接和日志调用。日志级别启用时保持原有输出格式和字段。测量对象
测量的是一次
_log_submission_evaluation_event(...)调用在日志级别关闭时的辅助函数开销,不是整条 HTTP 请求、RQ 作业或评测耗时。固定条件:
timeit -n 10000 -r 7tasks.submission_tasks.logger设置为CRITICALevent='finished'、submission_id=1、state='evaluated'、sandbox_status='none'基线
命令:
结果:
10000 loops, best of 7: 1.26 usec per loop。改动后
同一命令结果:
10000 loops, best of 7: 452 nsec per loop。在这个关闭日志级别的微基准中,单次调用耗时约降低 64%(约 1.26 usec 降到 0.452 usec)。这个数字只说明日志辅助函数的局部开销,不能外推为整条评测链路或用户请求快了 64%。
输出兼容性验证
命令:
结果:
1 passed, 20 warnings。实际输出仍包含:
回归验证
结果:
6 passed, 23 warnings。另外:
python -m compileall -q tasks/submission_tasks.py:通过git diff --check:通过范围和未优化部分
本 PR 只改变日志级别关闭时的辅助函数开销,不改变评测状态、分数、反馈、数据库写回、RQ 调度、C++ 沙箱、AI 调用或日志启用时的输出。
没有优化:
这些未在本次微基准中验证,也没有提交生产配置或凭据。