Skip to content

Commit ba4c2cd

Browse files
author
Memfault Inc
committed
memfaultd 1.15.0 (Build 2534584)
1 parent 3a9e0c5 commit ba4c2cd

File tree

115 files changed

+2890
-809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2890
-809
lines changed

Cargo.lock

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

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 2370319
2-
GIT COMMIT: 41269b2621
3-
VERSION: 1.14.0
1+
BUILD ID: 2534584
2+
GIT COMMIT: e2c67955b9
3+
VERSION: 1.15.0

memfault-ssf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "memfault-ssf"
3-
version = "1.14.0"
3+
version = "1.15.0"
44
edition = "2021"
55
description = "Supporting crate for the Memfault memfaultd embedded Linux agent"
66
homepage = "https://github.com/memfault/memfaultd"

memfault-ssf/VERSION

Whitespace-only changes.

memfaultc-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "memfaultc-sys"
3-
version = "1.14.0"
3+
version = "1.15.0"
44
edition = "2021"
55
autobins = false
66
description = "Supporting crate for the Memfault memfaultd embedded Linux agent"

memfaultc-sys/VERSION

Whitespace-only changes.

memfaultd/Cargo.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "memfaultd"
3-
version = "1.14.0"
3+
version = "1.15.0"
44
edition = "2021"
55
autobins = false
66
rust-version = "1.72"
@@ -28,8 +28,8 @@ name= "mfw"
2828
path= "src/bin/mfw.rs"
2929

3030
[dependencies]
31-
memfaultc-sys = { path= "../memfaultc-sys", version = "1.14.0" }
32-
ssf = { package = "memfault-ssf", path= "../memfault-ssf", version = "1.14.0" }
31+
memfaultc-sys = { path= "../memfaultc-sys", version = "1.15.0" }
32+
ssf = { package = "memfault-ssf", path= "../memfault-ssf", version = "1.15.0" }
3333
argh = "0.1.10"
3434
cfg-if = "1.0.0"
3535
chrono = { version = "0.4.23", features = ["serde"]}
@@ -50,7 +50,7 @@ serde_json = "1.0.89"
5050
serde_repr = "0.1"
5151
shuteye = "0.3.3"
5252
signal-hook = "0.3.14"
53-
stderrlog = "0.5.4"
53+
stderrlog = "0.6.0"
5454
strum = { version = "0.24", features = ["derive"] }
5555
strum_macros = "0.24"
5656
tempfile = "3.3.0"
@@ -73,6 +73,7 @@ regex= { version = "1.10.2", optional = true}
7373
nom = "7.1.3"
7474
sealed_test = "1.1.0"
7575
zip = { version = "1.1.4", default-features = false, features = ["deflate"]}
76+
lazy_static = "1.5.0"
7677

7778
[target.'cfg(target_os = "linux")'.dependencies]
7879
procfs = { version = "0.15.1", optional = true }
@@ -95,8 +96,12 @@ nom = "7.1.3"
9596
name = "logs_to_metrics"
9697
harness = false
9798

99+
[[bench]]
100+
name = "log_level_mapper"
101+
harness = false
102+
98103
[features]
99-
default = ["coredump", "collectd", "logging", "log-to-metrics", "systemd", "rust-tls" ]
104+
default = ["coredump", "logging", "regex", "systemd", "rust-tls"]
100105
coredump = [
101106
"memfaultc-sys/coredump",
102107
"dep:prctl",
@@ -107,13 +112,13 @@ coredump = [
107112
"dep:goblin",
108113
"dep:scroll"
109114
]
110-
collectd = []
111115
swupdate = ["memfaultc-sys/swupdate"]
112116
logging = ["dep:governor", "dep:rmp-serde", "dep:rmpv"]
113117
systemd = ["memfaultc-sys/systemd"]
114118
rust-tls = ["reqwest/rustls-tls"]
115119
openssl-tls = ["reqwest/native-tls"]
116120
openssl-vendored-tls = ["reqwest/native-tls-vendored"]
117-
log-to-metrics = ["dep:regex"]
121+
regex = ["dep:regex"]
122+
log-to-metrics = ["regex"]
118123
experimental = ["mfw"]
119124
mfw = []

memfaultd/DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apt install libsystemd-dev libconfig-dev
1616
#### macOS
1717

1818
```sh
19-
brew install libconfig
19+
brew install pkg-config libconfig
2020
```
2121

2222
(note: `libsystemd` is not available on macOS and the build system will not try

memfaultd/VERSION

Whitespace-only changes.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// Copyright (c) Memfault, Inc.
3+
// See License.txt for details
4+
use chrono::Utc;
5+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
6+
use memfaultd::config::{LevelMappingConfig, LevelMappingRegex};
7+
use memfaultd::logs::log_entry::{LogData, LogEntry};
8+
use memfaultd::logs::log_level_mapper::LogLevelMapper;
9+
10+
const BENCH_LEVELS: &[&str] = &[
11+
"EMERG", "ALERT", "CRIT", "ERROR", "WARN", "NOTICE", "INFO", "DEBUG",
12+
];
13+
14+
fn build_log_line(level: &str, message: &str) -> LogEntry {
15+
let data = LogData {
16+
message: message.to_string(),
17+
pid: None,
18+
systemd_unit: None,
19+
priority: Some(level.to_string()),
20+
original_priority: None,
21+
extra_fields: Default::default(),
22+
};
23+
24+
LogEntry {
25+
ts: Utc::now(),
26+
data,
27+
}
28+
}
29+
30+
fn build_regex_string(level: &str) -> String {
31+
format!(r"\[.*\] \[{}\]:", level)
32+
}
33+
34+
fn build_log_mapper() -> LogLevelMapper {
35+
let regex = BENCH_LEVELS
36+
.iter()
37+
.map(|level| build_regex_string(level))
38+
.collect::<Vec<_>>();
39+
40+
let regex = LevelMappingRegex {
41+
emergency: Some(regex[0].clone()),
42+
alert: Some(regex[1].clone()),
43+
critical: Some(regex[2].clone()),
44+
error: Some(regex[3].clone()),
45+
warning: Some(regex[4].clone()),
46+
notice: Some(regex[5].clone()),
47+
info: Some(regex[6].clone()),
48+
debug: Some(regex[7].clone()),
49+
};
50+
let level_config = LevelMappingConfig {
51+
enable: true,
52+
regex: Some(regex),
53+
};
54+
55+
LogLevelMapper::try_from(&level_config).expect("Failed to build log level mapper")
56+
}
57+
58+
fn map_logs(num_log_lines: u64, mapper: &LogLevelMapper) {
59+
for i in 0..num_log_lines {
60+
let cur_level_idx = i % BENCH_LEVELS.len() as u64;
61+
let cur_level = BENCH_LEVELS[cur_level_idx as usize];
62+
let mut log_line = build_log_line(cur_level, "This is a test log message");
63+
mapper.map_log(&mut log_line).expect("Error mapping log");
64+
}
65+
}
66+
67+
fn log_mapper_benchmark(c: &mut Criterion) {
68+
let mut group = c.benchmark_group("Log Level Mapper");
69+
let num_log_lines = [100, 1000];
70+
let level_mapper = build_log_mapper();
71+
72+
for num in num_log_lines {
73+
group.throughput(Throughput::Elements(num));
74+
group.bench_with_input(BenchmarkId::new("Log Level Mapper", num), &num, |b, num| {
75+
// Send metrics to preallocate the metrics hashmap
76+
b.iter(|| {
77+
map_logs(*num, &level_mapper);
78+
})
79+
});
80+
}
81+
}
82+
83+
criterion_group!(benches, log_mapper_benchmark);
84+
criterion_main!(benches);

0 commit comments

Comments
 (0)