-
Notifications
You must be signed in to change notification settings - Fork 398
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
optimize: 1. reserve metric events before parse log events, 2. use SetTagNoCopy in Relabel, 3. optimize the logic of delete labels which starts with "__" #1840
Conversation
// delete tag __<label_name> | ||
vector<StringView> toDelete; | ||
for (const auto& [k, v] : targetTags) { | ||
if (k.starts_with("__")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个特殊判断的什么场景,具体原因是什么?
很多地方都在用__判断,最好封装成一个函数,并注释下原因
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prom 中以 "__" 开头的 Label 是参加中间 Relabel 过程的,但在最后要删除掉,这次改动是因为之前对每个 MetricEvent 的所有 Tags 都进行了一次遍历,找到对应要删除的再删除。改动后,把它分布到了源头处 TargetLabels 和 MetricRelabel过程中,这样就避免了对 Group 中所有的 MetricEvent 的 Tags 进行全量遍历。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种偏特殊处理的,尽量收敛下,封装成函数吧。starts_with("__")
200*5000 场景优化前 181MB、0.733C,优化后150MB、0.686C, 对应18%的内存提升和7%的 CPU 提升