Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大量CPU时间被耗费在日志输出中 #366

Open
EquentR opened this issue Feb 20, 2025 · 4 comments
Open

大量CPU时间被耗费在日志输出中 #366

EquentR opened this issue Feb 20, 2025 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@EquentR
Copy link
Contributor

EquentR commented Feb 20, 2025

Image

Image

可能需要对这类日志输出进行限制,防止无效日志计算

@aceld
Copy link
Owner

aceld commented Feb 26, 2025

https://www.yuque.com/aceld/tsgooa/cx01fget6ka3wep1

Image

关了debug开关,再试试看看

@EquentR

@EquentR
Copy link
Contributor Author

EquentR commented Feb 26, 2025

试过了,level是2,主要耗时是在debug方法调用前的hex,不是debug本身

@aceld
Copy link
Owner

aceld commented Feb 27, 2025

@EquentR

嗯,我看了下,如果是消耗在之前的 hex.EncodeToString() 那确实需要改动的范围有点大,大致思考了下,需要动以下几个步骤:
1、给zlog提供获取当前日志级别的方法,比如zlog.Ins().DebugEnabled() 来判断当前配置的Debug级别。
2、梳理所有DebugF() 中有 ``hex.EncodeToString()` 形参的调用地方。
3、将梳理到的范围代码改成如下写法:

if zlog.Ins().IsDebugEnabled() {
    dataStr := hex.EncodeToString(request.GetData())
    zlog.Ins().DebugF("SendMsgToTaskQueue-->%s", dataStr)
}

@aceld aceld added the help wanted Extra attention is needed label Feb 27, 2025
@aceld
Copy link
Owner

aceld commented Feb 27, 2025

欢迎和期待有意愿的开发者,优化此问题,提交PR~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants