Skip to content

Commit 7a72b76

Browse files
qlndztkylewanginchina
authored andcommitted
add lua disable config
1 parent fc15030 commit 7a72b76

File tree

10 files changed

+108
-2
lines changed

10 files changed

+108
-2
lines changed

agent/src/config/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,7 @@ pub struct EbpfProfileLanguages {
12141214
pub python_disabled: bool,
12151215
pub php_disabled: bool,
12161216
pub nodejs_disabled: bool,
1217+
pub lua_disabled: bool,
12171218
}
12181219

12191220
impl Default for EbpfProfileLanguages {
@@ -1222,6 +1223,7 @@ impl Default for EbpfProfileLanguages {
12221223
python_disabled: false,
12231224
php_disabled: false,
12241225
nodejs_disabled: false,
1226+
lua_disabled: false,
12251227
}
12261228
}
12271229
}

agent/src/ebpf/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ pub const FEATURE_PROFILE_PYTHON: c_int = 9;
132132
pub const FEATURE_PROFILE_PHP: c_int = 10;
133133
#[allow(dead_code)]
134134
pub const FEATURE_PROFILE_V8: c_int = 11;
135+
#[allow(dead_code)]
136+
pub const FEATURE_PROFILE_LUA: c_int = 12;
135137

136138
//追踪器当前状态
137139
#[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
@@ -2055,6 +2055,11 @@ bool python_profiler_enabled(void)
20552055
return is_feature_regex_set(FEATURE_PROFILE_PYTHON);
20562056
}
20572057

2058+
bool lua_profiler_enabled(void)
2059+
{
2060+
return is_feature_regex_set(FEATURE_PROFILE_LUA);
2061+
}
2062+
20582063
static void init_thread_ids(void)
20592064
{
20602065
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 set_kick_kern_nice(int32_t nice);
634635
int tracer_bpf_load(struct bpf_tracer *tracer);

agent/src/ebpf_dispatcher.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,12 @@ impl EbpfCollector {
11431143
CString::new(".*").unwrap().as_c_str().as_ptr(),
11441144
);
11451145
}
1146+
if !languages.lua_disabled {
1147+
ebpf::set_feature_regex(
1148+
ebpf::FEATURE_PROFILE_LUA,
1149+
CString::new(".*").unwrap().as_c_str().as_ptr(),
1150+
);
1151+
}
11461152

11471153
#[cfg(feature = "extended_observability")]
11481154
{

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
@@ -5312,6 +5312,35 @@ inputs:
53125312
Disable Node.js (V8) interpreter profiling. When disabled, Node.js process stack traces will not be collected,
53135313
saving approximately 6.4 MB of kernel memory (v8_unwind_info_map).
53145314

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

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

0 commit comments

Comments
 (0)