-
Notifications
You must be signed in to change notification settings - Fork 389
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
feat: add ebpf plugins #2049
base: main
Are you sure you want to change the base?
feat: add ebpf plugins #2049
Conversation
KayzzzZ
commented
Jan 19, 2025
•
edited
Loading
edited
- 引入 coolbpf 子模块,作为 bpf 底座
- 新增 ebpf driver 目录,作为 coolbpf 的驱动
- AbstractManager 将负责管理每个 eBPF 插件,所有的 AbstractManagers 由 eBPFServer 管理
- SourceManager 仍然负责与 ebpf driver 交互,不过 eBPF Server 不再直接调用 SourceManager,转而由 AbstractManager 来调用
- 整体包括三组线程:Poller 线程负责拉取 eBPF PerfBuffer;Handler 线程负责处理 eBPF 事件;Scheduler 线程负责定时将聚合后的数据写入到 ProcessQueue 中
2. add sampler 3. add some ut
} | ||
} | ||
|
||
explicit Cache(size_t maxSize = 64, size_t elasticity = 10) : maxSize_(maxSize), elasticity_(elasticity) {} |
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.
因为我测试的时候发现这个库被改坏了,查不到缓存。我就用这个库最新的代码替换了一下
* limitations under the License. | ||
*/ | ||
|
||
#pragma once |
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.
这里单独定义一个span.h有点怪,跟之前的spanevent.h又是什么关系?
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.
跟spanevent没关系,这个span是boost 库里面的一个数据结构,表示对一段连续内存的视图。
这里之前是我自己写的 ArrayView,迅飞让我用 boost::span 来替换,引用方式与 boost::string_view 类似。
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.
Span.h StringView.h 移到 common目录下
return sTicksPerSecond; | ||
} | ||
|
||
std::chrono::nanoseconds GetTimeDiffFromMonotonic() { |
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.
因为 bpf 里面拿到的 timestamp 是内核启动以来的纳秒数,不是 UTC 时间
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.
返回 timespec
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.
TimerUtil 中实现 struct timespec KernelTimerToUTC(uint64_t nano) 方法,将内核时间戳转成 timespec
magic_enum::enum_name(mProtocol))("new protocol", magic_enum::enum_name(protocol))); | ||
} else { | ||
mProtocol = protocol; | ||
TryUpdateProtocolAttr(); |
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.
mark层次还是有些不统一,看看能否放到类的入口函数统一管理
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.
目前放的位置已经是最顶层了
return true; | ||
} | ||
|
||
void AsynCurlRunner::Stop() { | ||
if (mInited == false) { |
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.
@henryzhx8 类似的几个基础文件重点review下
continue; | ||
} | ||
|
||
it.second->TryAttachPeerMeta(mEnableMetadata); |
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.
mark的时机同理
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.
这4个标志位的 mark 时机,已经和迅飞对过了,这是我们一起对齐后的状态。
四个标志的mark 对应 4个方法:
TryAttachPeerMeta
TryAttachSelfMeta
TryUpdateProtocolAttr
UpdateNetMetaAttr
之所以前面三个是 TryXXX 是因为不确定是否能关联上对应的 meta,它们都需要依赖其他的事件、或者其他的元数据组合才能确定。只有第四个是确定的,收到conn stats event 就明确可以更新了。
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.
UpdateProtocol 和 UpdateRole 合并成 TryAttachL7Meta,在 conn_stats_event 和 data_event 事件的回调中调用;
TryAttachPeerMeta 和 TryAttachSelfMeta 从 UpdateL4Meta 中独立出来,在 conn_stats_event 的回调中第一次调用,在 Iterations 中的调用和rollback 中的调用尚未达成一致。