Skip to content
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: 1 addition & 1 deletion agent/src/ebpf/user/profile/java/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define DF_JAVA_CONFIG_H

// Maximum length of Java symbol information string
#define STRING_BUFFER_SIZE 2000
#define STRING_BUFFER_SIZE 2048
/*
* In Unix domain sockets, the maximum length of the path is defined by
* the macro UNIX_PATH_MAX. For most systems (e.g., Linux), this maximum
Expand Down
1 change: 0 additions & 1 deletion agent/src/ebpf/user/profile/java/jvm_symbol_collect.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "config.h"

#define STRING_BUFFER_SIZE 2000
#define UNIX_PATH_MAX 108
#define JAVA_ADDR_STR_SIZE 13

Expand Down
30 changes: 29 additions & 1 deletion agent/src/ebpf/user/profile/java/symbol_collect_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ char perf_log_socket_path[128];

int perf_map_socket_fd = -1;
int perf_map_log_socket_fd = -1;

// Cache symbols for batch sending
char g_symbol_buffer[STRING_BUFFER_SIZE * 4];
int g_cached_bytes;
jint close_files(void);

#define _(e) \
Expand Down Expand Up @@ -301,6 +305,7 @@ void df_send_symbol(enum event_type type, const void *code_addr,
return;
}

int send_bytes;
struct symbol_metadata *meta;
char symbol_str[STRING_BUFFER_SIZE];
if (type == METHOD_UNLOAD) {
Expand All @@ -315,8 +320,30 @@ void df_send_symbol(enum event_type type, const void *code_addr,
meta = (struct symbol_metadata *)symbol_str;
meta->len = strlen(symbol_str + sizeof(*meta));
meta->type = type;
send_bytes = meta->len + sizeof(*meta);
pthread_mutex_lock(&g_df_lock);
send_msg(perf_map_socket_fd, symbol_str, meta->len + sizeof(*meta));
if (replay_finish) {
if (g_cached_bytes > 0) {
send_msg(perf_map_socket_fd, g_symbol_buffer,
g_cached_bytes);
g_cached_bytes = 0;
}
send_msg(perf_map_socket_fd, symbol_str, send_bytes);
} else {
int buff_remain_bytes =
sizeof(g_symbol_buffer) - g_cached_bytes;
if (buff_remain_bytes >= send_bytes) {
memcpy(g_symbol_buffer + g_cached_bytes, symbol_str,
send_bytes);
g_cached_bytes += send_bytes;
} else {
send_msg(perf_map_socket_fd, g_symbol_buffer,
g_cached_bytes);
memcpy(g_symbol_buffer, symbol_str, send_bytes);
g_cached_bytes = send_bytes;
}
}

if (!replay_finish)
replay_count++;
pthread_mutex_unlock(&g_df_lock);
Expand Down Expand Up @@ -505,6 +532,7 @@ Agent_OnAttach(JavaVM * vm, char *options, void *reserved)
_(get_jvmti_env(vm, &jvmti));

enable_replay:
g_cached_bytes = 0;
_(df_agent_config(options));
_(open_perf_map_log_file(getpid()));
_(open_perf_map_file(getpid()));
Expand Down