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

fix: agent - eBPF Correct the maximum data push delay #8694

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions agent/src/ebpf/kernel/include/socket_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#define INFER_CONTINUE 1
#define INFER_TERMINATE 2

#define MAX_PUSH_DELAY_TIME_NS 100000000ULL // 100ms

typedef long unsigned int __kernel_size_t;

enum {
Expand Down
14 changes: 5 additions & 9 deletions agent/src/ebpf/kernel/socket_trace.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2734,16 +2734,9 @@ static __inline int finalize_data_output(void *ctx,
v_buff->events_num = 0;
v_buff->len = 0;
if (diff > PERIODIC_PUSH_DELAY_THRESHOLD_NS) {
__u32 k0 = 0;
struct trace_stats *stats;
tracer_ctx->last_period_timestamp =
tracer_ctx->period_timestamp;
tracer_ctx->period_timestamp = curr_time;
stats = trace_stats_map__lookup(&k0);
if (stats == NULL)
return -1;
if (diff > stats->period_event_max_delay)
stats->period_event_max_delay = diff;
}

return 0;
Expand Down Expand Up @@ -3384,8 +3377,11 @@ static __inline int push_socket_data(struct syscall_comm_enter_ctx *ctx)

v_buff->events_num = 0;
v_buff->len = 0;
if (diff > trace_stats->period_event_max_delay)
trace_stats->period_event_max_delay = diff;
if (diff > MAX_PUSH_DELAY_TIME_NS) {
// Indicates that a delay occurred in this data push.
__sync_fetch_and_add(&trace_stats->period_event_max_delay, 1);
}

}
}

Expand Down
7 changes: 6 additions & 1 deletion agent/src/ebpf/user/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,12 @@ enum cfg_feature_idx {
* the data resident in the eBPF buffer. This value is the periodic time, unit
* is milliseconds.
*/
#define KICK_KERN_PERIOD 40000000 // Set default interval to 30 milliseconds
#define KICK_KERN_PERIOD 40000000 // Set default interval to 40 milliseconds
/*
* A special value should be assigned to indicate the case where no data has
* been pushed after exceeding 100 milliseconds.
*/
#define PUSH_DELAY_EXCEEDED_MARKER 199000 // 199 ms

/*
* timer config
Expand Down
3 changes: 1 addition & 2 deletions agent/src/ebpf/user/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2701,8 +2701,7 @@ struct socket_trace_stats socket_tracer_stats(void)
stats_total.period_event_count) / NS_IN_USEC;

if (stats_total.period_event_max_delay > 0) {
stats.period_push_max_delay =
stats_total.period_event_max_delay / NS_IN_USEC;
stats.period_push_max_delay = PUSH_DELAY_EXCEEDED_MARKER;
} else {
stats.period_push_max_delay = stats.period_push_avg_delay;
}
Expand Down
Loading