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

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

Merged
merged 8 commits into from
Nov 6, 2024

Conversation

catdogpandas
Copy link
Contributor

@catdogpandas catdogpandas commented Oct 29, 2024

200*5000 场景优化前 181MB、0.733C,优化后150MB、0.686C, 对应18%的内存提升和7%的 CPU 提升

// delete tag __<label_name>
vector<StringView> toDelete;
for (const auto& [k, v] : targetTags) {
if (k.starts_with("__")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个特殊判断的什么场景,具体原因是什么?

很多地方都在用__判断,最好封装成一个函数,并注释下原因

Copy link
Contributor Author

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 进行全量遍历。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种偏特殊处理的,尽量收敛下,封装成函数吧。starts_with("__")

@henryzhx8 henryzhx8 added the enhancement Feature enhancement label Nov 1, 2024
@henryzhx8 henryzhx8 added this to the v2.2 milestone Nov 1, 2024
@linrunqi08 linrunqi08 merged commit a34c7dd into alibaba:main Nov 6, 2024
15 checks passed
@catdogpandas catdogpandas deleted the optimize/memory-and-cpu branch November 6, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants