Skip to content

Conversation

saying121
Copy link
Contributor

No description provided.

@saying121 saying121 requested a review from BrytonLee September 25, 2025 08:59
@saying121 saying121 force-pushed the sampling branch 2 times, most recently from 03d688e to 1e5b027 Compare September 25, 2025 09:15
let mut data = vec![];
for ele in &perf_data.events {
let Some(event_type) = &ele.event_type else {
continue;
Copy link
Member

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.

event_type 在proto里面是用 oneof定义, oneof event_type {,使用oneof就会生成一个option的字段,这里没有就跳过是合适的。


if let psh_proto::perf_data_proto::perf_event::EventType::MmapEvent(event)= event_type{
let Some(filename) = &event.filename else {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

同上

.await??;
if let Some(task_id) = profiling_task.id {
let mut data = vec![];
for ele in &perf_data.events {
Copy link
Member

Choose a reason for hiding this comment

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

ele -> event?

if let Some(task_id) = profiling_task.id {
let mut data = vec![];
for ele in &perf_data.events {
let Some(event_type) = &ele.event_type else {
Copy link
Member

Choose a reason for hiding this comment

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

读取ELF文件为什么需要event_type? 这个不是强关联吧?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

文件名是在MmapEvent里面的,所以需要从里面获取文件名。

let dat = Data {
data_type: Some(DataType::PerfData(perf_data)),
};
data.push(dat);
Copy link
Member

Choose a reason for hiding this comment

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

采样和上传ELF文件两个可以分开,放在一起反而不方便。不是所有的ELF文件都需要上传。

filename: filename.to_owned(),
build_id: event.build_id.clone(),
arch: std::env::consts::ARCH.to_string(),
bytes: tokio::fs::read(filename).await?
Copy link
Member

Choose a reason for hiding this comment

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

应该是先做一些校验,然后在判断是不是要读取文件内容,而不是直接读取。比如文件不存在怎么处理, build_id不一致怎么处理,用户是否允许读取某个文件/目录等等。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants