Skip to content

Commit db1c033

Browse files
author
Meridian House
committed
perf: memory optimization — jemalloc, 2 worker threads, Box<str> for datasets
- Added tikv-jemallocator for better long-running memory behavior - Reduced tokio worker threads from default to 2 (I/O bound workload) - Switched dataset string fields to Box<str> to reduce heap overhead - Startup RSS down from 64MB to 38MB
1 parent b7edccf commit db1c033

File tree

5 files changed

+227
-107
lines changed

5 files changed

+227
-107
lines changed

Cargo.lock

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ resolver = "2"
1717

1818
[workspace.dependencies]
1919
tokio = { version = "1", features = ["full"] }
20-
serde = { version = "1", features = ["derive"] }
20+
serde = { version = "1", features = ["derive", "rc"] }
2121
serde_yaml = "0.9"
2222
serde_json = "1"
2323
clap = { version = "4", features = ["derive"] }
2424
tracing = "0.1"
2525
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter", "json"] }
2626
chrono = { version = "0.4", features = ["serde"] }
2727
procfs = "0.17"
28-
reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false }
28+
reqwest = { version = "0.12", features = ["json", "rustls-tls", "gzip"], default-features = false }
2929
notify = "6"
3030
blake3 = "1"
3131
sha3 = "0.10"
@@ -63,6 +63,9 @@ tar.workspace = true
6363
nu-ansi-term = "0.50.3"
6464
anyhow = { path = "third_party/anyhow" }
6565

66+
[target.'cfg(target_os = "linux")'.dependencies]
67+
tikv-jemallocator = "0.6"
68+
6669
[dev-dependencies]
6770
quickcheck = { path = "third_party/quickcheck" }
6871
criterion = { path = "third_party/criterion" }

src/collector.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ fn normalize_exec_token(input: &str) -> String {
17901790
fn has_dangerous_gtfobin_capabilities(info: &GtfobinInfo) -> bool {
17911791
info.functions.iter().any(|capability| {
17921792
matches!(
1793-
capability.as_str(),
1793+
&**capability,
17941794
"shell" | "suid" | "sudo" | "reverse-shell" | "bind-shell" | "file-write"
17951795
)
17961796
})
@@ -2537,9 +2537,9 @@ mod tests {
25372537
datasets.rmm_tools.insert(
25382538
"anydesk".to_string(),
25392539
RmmToolInfo {
2540-
name: "AnyDesk".to_string(),
2541-
description: "Remote desktop".to_string(),
2542-
reference_url: "https://lolrmm.io/".to_string(),
2540+
name: "AnyDesk".into(),
2541+
description: "Remote desktop".into(),
2542+
reference_url: "https://lolrmm.io/".into(),
25432543
installation_paths: vec![],
25442544
},
25452545
);
@@ -2614,8 +2614,8 @@ mod tests {
26142614
datasets.gtfobins.insert(
26152615
"python".to_string(),
26162616
GtfobinInfo {
2617-
name: "python".to_string(),
2618-
functions: vec!["shell".to_string(), "file-read".to_string()],
2617+
name: "python".into(),
2618+
functions: vec!["shell".into(), "file-read".into()],
26192619
},
26202620
);
26212621
collector.datasets = Some(datasets);
@@ -2689,9 +2689,9 @@ mod tests {
26892689
datasets.tunnels.insert(
26902690
"ngrok".to_string(),
26912691
TunnelToolInfo {
2692-
name: "ngrok".to_string(),
2693-
description: "Public tunnel service".to_string(),
2694-
capabilities: vec!["c2".to_string(), "exfiltration".to_string()],
2692+
name: "ngrok".into(),
2693+
description: "Public tunnel service".into(),
2694+
capabilities: vec!["c2".into(), "exfiltration".into()],
26952695
},
26962696
);
26972697
collector.datasets = Some(datasets);
@@ -2765,10 +2765,10 @@ mod tests {
27652765
datasets.c2_tools.insert(
27662766
"sliver".to_string(),
27672767
C2ToolInfo {
2768-
name: "Sliver".to_string(),
2769-
description: "C2 over legitimate channels".to_string(),
2770-
abused_services: vec!["discord".to_string(), "slack".to_string()],
2771-
reference_url: "https://lolc2.github.io/".to_string(),
2768+
name: "Sliver".into(),
2769+
description: "C2 over legitimate channels".into(),
2770+
abused_services: vec!["discord".into(), "slack".into()],
2771+
reference_url: "https://lolc2.github.io/".into(),
27722772
},
27732773
);
27742774
collector.datasets = Some(datasets);

0 commit comments

Comments
 (0)