Skip to content

Commit 35ca959

Browse files
committed
feat: add lua disable config
1 parent 44fbe25 commit 35ca959

10 files changed

Lines changed: 108 additions & 2 deletions

File tree

agent/src/config/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ pub struct EbpfProfileLanguages {
12101210
pub python_disabled: bool,
12111211
pub php_disabled: bool,
12121212
pub nodejs_disabled: bool,
1213+
pub lua_disabled: bool,
12131214
}
12141215

12151216
impl Default for EbpfProfileLanguages {
@@ -1218,6 +1219,7 @@ impl Default for EbpfProfileLanguages {
12181219
python_disabled: false,
12191220
php_disabled: false,
12201221
nodejs_disabled: false,
1222+
lua_disabled: false,
12211223
}
12221224
}
12231225
}

agent/src/ebpf/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ pub const FEATURE_PROFILE_PYTHON: c_int = 9;
128128
pub const FEATURE_PROFILE_PHP: c_int = 10;
129129
#[allow(dead_code)]
130130
pub const FEATURE_PROFILE_V8: c_int = 11;
131+
#[allow(dead_code)]
132+
pub const FEATURE_PROFILE_LUA: c_int = 12;
131133

132134
//追踪器当前状态
133135
#[allow(dead_code)]

agent/src/ebpf/user/config.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
#define PROG_ONCPU_OUTPUT_FOR_PE "df_PE_oncpu_output"
9090

9191
// lua related maps
92-
#define MAP_LUA_LANG_FLAGS_NAME "__lang_flags_map"
92+
#define MAP_LUA_LANG_FLAGS_NAME "__lua_lang_flags_map"
9393
#define MAP_LUA_UNWIND_INFO_NAME "__lua_unwind_info_map"
9494
#define MAP_LUA_OFFSETS_NAME "__lua_offsets_map"
9595
#define MAP_LUAJIT_OFFSETS_NAME "__luajit_offsets_map"
@@ -181,6 +181,7 @@ enum cfg_feature_idx {
181181
FEATURE_PROFILE_PYTHON,
182182
FEATURE_PROFILE_PHP,
183183
FEATURE_PROFILE_V8,
184+
FEATURE_PROFILE_LUA,
184185
FEATURE_CPU_BALANCER,
185186
FEATURE_MAX,
186187
};
@@ -196,6 +197,7 @@ enum cfg_feature_idx {
196197
#define FEATURE_FLAG_PROFILE_PYTHON (1 << FEATURE_PROFILE_PYTHON)
197198
#define FEATURE_FLAG_PROFILE_PHP (1 << FEATURE_PROFILE_PHP)
198199
#define FEATURE_FLAG_PROFILE_V8 (1 << FEATURE_PROFILE_V8)
200+
#define FEATURE_FLAG_PROFILE_LUA (1 << FEATURE_PROFILE_LUA)
199201
#define FEATURE_FLAG_CPU_BALANCER (1 << FEATURE_CPU_BALANCER)
200202

201203
#define FEATURE_FLAG_PROFILE (FEATURE_FLAG_PROFILE_ONCPU | FEATURE_FLAG_PROFILE_OFFCPU | FEATURE_FLAG_PROFILE_MEMORY)

agent/src/ebpf/user/load.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,9 @@ int ebpf_obj_load(struct ebpf_object *obj)
13381338
if (!python_profiler_enabled()) {
13391339
enabled_feats &= ~FEATURE_FLAG_PROFILE_PYTHON;
13401340
}
1341+
if (!lua_profiler_enabled()) {
1342+
enabled_feats &= ~FEATURE_FLAG_PROFILE_LUA;
1343+
}
13411344
enabled_feats &= ~extended_feature_flags(map);
13421345
if (enabled_feats == 0 &&
13431346
map->def.type != BPF_MAP_TYPE_PROG_ARRAY &&
@@ -1359,7 +1362,8 @@ int ebpf_obj_load(struct ebpf_object *obj)
13591362
}
13601363
// Log language profiler map creation with max_entries for verification
13611364
if (strstr(map->name, "php_") || strstr(map->name, "v8_") ||
1362-
strstr(map->name, "python_")) {
1365+
strstr(map->name, "python_") || strstr(map->name, "lua_") ||
1366+
strstr(map->name, "luajit_")) {
13631367
ebpf_info
13641368
("Language profiler map created: name=%s, max_entries=%d (1 means disabled)\n",
13651369
map->name, map->def.max_entries);

agent/src/ebpf/user/tracer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,11 @@ bool python_profiler_enabled(void)
20232023
return is_feature_regex_set(FEATURE_PROFILE_PYTHON);
20242024
}
20252025

2026+
bool lua_profiler_enabled(void)
2027+
{
2028+
return is_feature_regex_set(FEATURE_PROFILE_LUA);
2029+
}
2030+
20262031
static void init_thread_ids(void)
20272032
{
20282033
thread_ids.entries = NULL;

agent/src/ebpf/user/tracer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ bool is_feature_regex_set(int feature);
629629
bool php_profiler_enabled(void);
630630
bool v8_profiler_enabled(void);
631631
bool python_profiler_enabled(void);
632+
bool lua_profiler_enabled(void);
632633
int bpf_tracer_init(const char *log_file, bool is_stdout);
633634
int tracer_bpf_load(struct bpf_tracer *tracer);
634635
int tracer_probes_init(struct bpf_tracer *tracer);

agent/src/ebpf_dispatcher.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,12 @@ impl EbpfCollector {
11311131
CString::new(".*").unwrap().as_c_str().as_ptr(),
11321132
);
11331133
}
1134+
if !languages.lua_disabled {
1135+
ebpf::set_feature_regex(
1136+
ebpf::FEATURE_PROFILE_LUA,
1137+
CString::new(".*").unwrap().as_c_str().as_ptr(),
1138+
);
1139+
}
11341140

11351141
#[cfg(feature = "extended_observability")]
11361142
{

server/agent_config/README-CH.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5172,6 +5172,35 @@ inputs:
51725172
禁用 Node.js(V8)解释器剖析。禁用后将不采集 Node.js 进程的函数调用栈,
51735173
可节省约 6.4 MB 内核内存(v8_unwind_info_map)。
51745174

5175+
##### 禁用 Lua 剖析 {#inputs.ebpf.profile.languages.lua_disabled}
5176+
5177+
**标签**:
5178+
5179+
<mark>agent_restart</mark>
5180+
5181+
**FQCN**:
5182+
5183+
`inputs.ebpf.profile.languages.lua_disabled`
5184+
5185+
**默认值**:
5186+
```yaml
5187+
inputs:
5188+
ebpf:
5189+
profile:
5190+
languages:
5191+
lua_disabled: false
5192+
```
5193+
5194+
**模式**:
5195+
| Key | Value |
5196+
| ---- | ---------------------------- |
5197+
| Type | bool |
5198+
5199+
**详细描述**:
5200+
5201+
禁用 Lua 解释器剖析。禁用后将不采集 Lua 进程的函数调用栈,
5202+
可节省约 13 MB 内核内存(lua_tstate_map、lua_lang_flags_map、lua_unwind_info_map、lua_offsets_map、luajit_offsets_map)。
5203+
51755204
### 网络 {#inputs.ebpf.network}
51765205

51775206
#### NIC optimization Enabled {#inputs.ebpf.network.nic_opt_enabled}

server/agent_config/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5311,6 +5311,35 @@ inputs:
53115311
Disable Node.js (V8) interpreter profiling. When disabled, Node.js process stack traces will not be collected,
53125312
saving approximately 6.4 MB of kernel memory (v8_unwind_info_map).
53135313

5314+
##### Lua profiling disabled {#inputs.ebpf.profile.languages.lua_disabled}
5315+
5316+
**Tags**:
5317+
5318+
<mark>agent_restart</mark>
5319+
5320+
**FQCN**:
5321+
5322+
`inputs.ebpf.profile.languages.lua_disabled`
5323+
5324+
**Default value**:
5325+
```yaml
5326+
inputs:
5327+
ebpf:
5328+
profile:
5329+
languages:
5330+
lua_disabled: false
5331+
```
5332+
5333+
**Schema**:
5334+
| Key | Value |
5335+
| ---- | ---------------------------- |
5336+
| Type | bool |
5337+
5338+
**Description**:
5339+
5340+
Disable Lua interpreter profiling. When disabled, Lua process stack traces will not be collected,
5341+
saving approximately 13 MB of kernel memory (lua_tstate_map, lua_lang_flags_map, lua_unwind_info_map, lua_offsets_map, luajit_offsets_map).
5342+
53145343
### Network {#inputs.ebpf.network}
53155344

53165345
#### NIC optimization Enabled {#inputs.ebpf.network.nic_opt_enabled}

server/agent_config/template.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,6 +3873,32 @@ inputs:
38733873
# 禁用 Node.js(V8)解释器剖析。禁用后将不采集 Node.js 进程的函数调用栈,
38743874
# 可节省约 6.4 MB 内核内存(v8_unwind_info_map)。
38753875
nodejs_disabled: false
3876+
# type: bool
3877+
# name:
3878+
# en: Lua profiling disabled
3879+
# ch: 禁用 Lua 剖析
3880+
# unit:
3881+
# range: []
3882+
# enum_options: []
3883+
# modification: agent_restart
3884+
# ee_feature: false
3885+
# description:
3886+
# en: |-
3887+
# Disable Lua interpreter profiling. When disabled, Lua process stack traces will not be collected,
3888+
# saving approximately 13 MB of kernel memory.
3889+
# This controls the following eBPF maps:
3890+
# - lua_tstate_map: Per-thread lua_State cache (~7 MB)
3891+
# - lua_lang_flags_map: Per-process Lua/LuaJIT type flags (~2.5 MB)
3892+
# - lua_unwind_info_map: Per-process unwinding metadata (~3 MB)
3893+
# - lua_offsets_map, luajit_offsets_map: Lua/LuaJIT struct offset tables (< 2 KB total)
3894+
# ch: |-
3895+
# 禁用 Lua 解释器剖析功能。禁用后将不会采集 Lua 进程的函数调用栈,可节省约 13 MB 的内核内存。
3896+
# 此配置项控制以下 eBPF maps 的创建:
3897+
# - lua_tstate_map:缓存每线程 lua_State 栈(按线程,容量较大,约 7 MB)
3898+
# - lua_lang_flags_map:记录进程 Lua/LuaJIT 类型标记(约 2.5 MB)
3899+
# - lua_unwind_info_map:存储进程级 unwinding 元信息(约 3 MB)
3900+
# - lua_offsets_map、luajit_offsets_map:存储 Lua/LuaJIT 结构偏移表(总计 < 2 KB)
3901+
lua_disabled: false
38763902
# type: section
38773903
# name:
38783904
# en: Network

0 commit comments

Comments
 (0)