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: 2 additions & 0 deletions agent/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ pub struct EbpfProfileLanguages {
pub python_disabled: bool,
pub php_disabled: bool,
pub nodejs_disabled: bool,
pub lua_disabled: bool,
}

impl Default for EbpfProfileLanguages {
Expand All @@ -1222,6 +1223,7 @@ impl Default for EbpfProfileLanguages {
python_disabled: false,
php_disabled: false,
nodejs_disabled: false,
lua_disabled: false,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions agent/src/ebpf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ pub const FEATURE_PROFILE_PYTHON: c_int = 9;
pub const FEATURE_PROFILE_PHP: c_int = 10;
#[allow(dead_code)]
pub const FEATURE_PROFILE_V8: c_int = 11;
#[allow(dead_code)]
pub const FEATURE_PROFILE_LUA: c_int = 12;

//追踪器当前状态
#[allow(dead_code)]
Expand Down
4 changes: 3 additions & 1 deletion agent/src/ebpf/user/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#define PROG_ONCPU_OUTPUT_FOR_PE "df_PE_oncpu_output"

// lua related maps
#define MAP_LUA_LANG_FLAGS_NAME "__lang_flags_map"
#define MAP_LUA_LANG_FLAGS_NAME "__lua_lang_flags_map"
#define MAP_LUA_UNWIND_INFO_NAME "__lua_unwind_info_map"
#define MAP_LUA_OFFSETS_NAME "__lua_offsets_map"
#define MAP_LUAJIT_OFFSETS_NAME "__luajit_offsets_map"
Expand Down Expand Up @@ -181,6 +181,7 @@ enum cfg_feature_idx {
FEATURE_PROFILE_PYTHON,
FEATURE_PROFILE_PHP,
FEATURE_PROFILE_V8,
FEATURE_PROFILE_LUA,
FEATURE_CPU_BALANCER,
FEATURE_MAX,
};
Expand All @@ -196,6 +197,7 @@ enum cfg_feature_idx {
#define FEATURE_FLAG_PROFILE_PYTHON (1 << FEATURE_PROFILE_PYTHON)
#define FEATURE_FLAG_PROFILE_PHP (1 << FEATURE_PROFILE_PHP)
#define FEATURE_FLAG_PROFILE_V8 (1 << FEATURE_PROFILE_V8)
#define FEATURE_FLAG_PROFILE_LUA (1 << FEATURE_PROFILE_LUA)
#define FEATURE_FLAG_CPU_BALANCER (1 << FEATURE_CPU_BALANCER)

#define FEATURE_FLAG_PROFILE (FEATURE_FLAG_PROFILE_ONCPU | FEATURE_FLAG_PROFILE_OFFCPU | FEATURE_FLAG_PROFILE_MEMORY)
Expand Down
6 changes: 5 additions & 1 deletion agent/src/ebpf/user/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,9 @@ int ebpf_obj_load(struct ebpf_object *obj)
if (!python_profiler_enabled()) {
enabled_feats &= ~FEATURE_FLAG_PROFILE_PYTHON;
}
if (!lua_profiler_enabled()) {
enabled_feats &= ~FEATURE_FLAG_PROFILE_LUA;
}
enabled_feats &= ~extended_feature_flags(map);
if (enabled_feats == 0 &&
map->def.type != BPF_MAP_TYPE_PROG_ARRAY &&
Expand All @@ -1359,7 +1362,8 @@ int ebpf_obj_load(struct ebpf_object *obj)
}
// Log language profiler map creation with max_entries for verification
if (strstr(map->name, "php_") || strstr(map->name, "v8_") ||
strstr(map->name, "python_")) {
strstr(map->name, "python_") || strstr(map->name, "lua_") ||
strstr(map->name, "luajit_")) {
ebpf_info
("Language profiler map created: name=%s, max_entries=%d (1 means disabled)\n",
map->name, map->def.max_entries);
Expand Down
5 changes: 5 additions & 0 deletions agent/src/ebpf/user/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,11 @@ bool python_profiler_enabled(void)
return is_feature_regex_set(FEATURE_PROFILE_PYTHON);
}

bool lua_profiler_enabled(void)
{
return is_feature_regex_set(FEATURE_PROFILE_LUA);
}

static void init_thread_ids(void)
{
thread_ids.entries = NULL;
Expand Down
1 change: 1 addition & 0 deletions agent/src/ebpf/user/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ bool is_feature_regex_set(int feature);
bool php_profiler_enabled(void);
bool v8_profiler_enabled(void);
bool python_profiler_enabled(void);
bool lua_profiler_enabled(void);
int bpf_tracer_init(const char *log_file, bool is_stdout);
int set_kick_kern_nice(int32_t nice);
int tracer_bpf_load(struct bpf_tracer *tracer);
Expand Down
6 changes: 6 additions & 0 deletions agent/src/ebpf_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,12 @@ impl EbpfCollector {
CString::new(".*").unwrap().as_c_str().as_ptr(),
);
}
if !languages.lua_disabled {
ebpf::set_feature_regex(
ebpf::FEATURE_PROFILE_LUA,
CString::new(".*").unwrap().as_c_str().as_ptr(),
);
}

#[cfg(feature = "extended_observability")]
{
Expand Down
29 changes: 29 additions & 0 deletions server/agent_config/README-CH.md
Original file line number Diff line number Diff line change
Expand Up @@ -5172,6 +5172,35 @@ inputs:
禁用 Node.js(V8)解释器剖析。禁用后将不采集 Node.js 进程的函数调用栈,
可节省约 6.4 MB 内核内存(v8_unwind_info_map)。

##### 禁用 Lua 剖析 {#inputs.ebpf.profile.languages.lua_disabled}

**标签**:

<mark>agent_restart</mark>

**FQCN**:

`inputs.ebpf.profile.languages.lua_disabled`

**默认值**:
```yaml
inputs:
ebpf:
profile:
languages:
lua_disabled: false
```

**模式**:
| Key | Value |
| ---- | ---------------------------- |
| Type | bool |

**详细描述**:

禁用 Lua 解释器剖析。禁用后将不采集 Lua 进程的函数调用栈,
可节省约 13 MB 内核内存(lua_tstate_map、lua_lang_flags_map、lua_unwind_info_map、lua_offsets_map、luajit_offsets_map)。

### 网络 {#inputs.ebpf.network}

#### NIC optimization Enabled {#inputs.ebpf.network.nic_opt_enabled}
Expand Down
29 changes: 29 additions & 0 deletions server/agent_config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5312,6 +5312,35 @@ inputs:
Disable Node.js (V8) interpreter profiling. When disabled, Node.js process stack traces will not be collected,
saving approximately 6.4 MB of kernel memory (v8_unwind_info_map).

##### Lua profiling disabled {#inputs.ebpf.profile.languages.lua_disabled}

**Tags**:

<mark>agent_restart</mark>

**FQCN**:

`inputs.ebpf.profile.languages.lua_disabled`

**Default value**:
```yaml
inputs:
ebpf:
profile:
languages:
lua_disabled: false
```

**Schema**:
| Key | Value |
| ---- | ---------------------------- |
| Type | bool |

**Description**:

Disable Lua interpreter profiling. When disabled, Lua process stack traces will not be collected,
saving approximately 13 MB of kernel memory (lua_tstate_map, lua_lang_flags_map, lua_unwind_info_map, lua_offsets_map, luajit_offsets_map).

### Network {#inputs.ebpf.network}

#### NIC optimization Enabled {#inputs.ebpf.network.nic_opt_enabled}
Expand Down
26 changes: 26 additions & 0 deletions server/agent_config/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3874,6 +3874,32 @@ inputs:
# 禁用 Node.js(V8)解释器剖析。禁用后将不采集 Node.js 进程的函数调用栈,
# 可节省约 6.4 MB 内核内存(v8_unwind_info_map)。
nodejs_disabled: false
# type: bool
# name:
# en: Lua profiling disabled
# ch: 禁用 Lua 剖析
# unit:
# range: []
# enum_options: []
# modification: agent_restart
# ee_feature: false
# description:
# en: |-
# Disable Lua interpreter profiling. When disabled, Lua process stack traces will not be collected,
# saving approximately 13 MB of kernel memory.
# This controls the following eBPF maps:
# - lua_tstate_map: Per-thread lua_State cache (~7 MB)
# - lua_lang_flags_map: Per-process Lua/LuaJIT type flags (~2.5 MB)
# - lua_unwind_info_map: Per-process unwinding metadata (~3 MB)
# - lua_offsets_map, luajit_offsets_map: Lua/LuaJIT struct offset tables (< 2 KB total)
# ch: |-
# 禁用 Lua 解释器剖析功能。禁用后将不会采集 Lua 进程的函数调用栈,可节省约 13 MB 的内核内存。
# 此配置项控制以下 eBPF maps 的创建:
# - lua_tstate_map:缓存每线程 lua_State 栈(按线程,容量较大,约 7 MB)
# - lua_lang_flags_map:记录进程 Lua/LuaJIT 类型标记(约 2.5 MB)
# - lua_unwind_info_map:存储进程级 unwinding 元信息(约 3 MB)
# - lua_offsets_map、luajit_offsets_map:存储 Lua/LuaJIT 结构偏移表(总计 < 2 KB)
lua_disabled: false
# type: section
# name:
# en: Network
Expand Down
Loading