diff --git a/Cargo.lock b/Cargo.lock index d85b4f740..3efc75048 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,6 +49,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "anstream" version = "1.0.0" @@ -494,6 +500,16 @@ dependencies = [ "walkdir", ] +[[package]] +name = "bd-client-regex" +version = "1.0.0" +dependencies = [ + "bd-workspace-hack", + "criterion", + "regex", + "regex-lite", +] + [[package]] name = "bd-client-stats" version = "1.0.0" @@ -568,6 +584,7 @@ dependencies = [ "bd-api", "bd-artifact-upload", "bd-client-common", + "bd-client-regex", "bd-client-stats-store", "bd-device", "bd-error-reporter", @@ -591,7 +608,6 @@ dependencies = [ "memmap2", "mockall", "notify", - "regex", "tempfile", "thiserror 2.0.18", "time", @@ -799,6 +815,7 @@ version = "1.0.0" dependencies = [ "anyhow", "assert_matches", + "bd-client-regex", "bd-client-stats-store", "bd-log-matcher", "bd-log-primitives", @@ -811,7 +828,6 @@ dependencies = [ "itertools 0.14.0", "log", "pretty_assertions", - "regex", "time", ] @@ -822,6 +838,7 @@ dependencies = [ "ahash", "anyhow", "assert_matches", + "bd-client-regex", "bd-log-primitives", "bd-proto", "bd-state", @@ -833,7 +850,6 @@ dependencies = [ "pretty_assertions", "protobuf 4.0.0-alpha.0", "rand 0.10.1", - "regex", "tempfile", "time", "tokio", @@ -1378,6 +1394,7 @@ dependencies = [ "async-trait", "bd-api", "bd-client-common", + "bd-client-regex", "bd-client-stats", "bd-client-stats-store", "bd-completion", @@ -1404,7 +1421,6 @@ dependencies = [ "parking_lot", "pretty_assertions", "protobuf 4.0.0-alpha.0", - "regex", "serde", "sha2", "simplelog", @@ -1462,6 +1478,7 @@ dependencies = [ "tracing", "tracing-core", "winnow 1.0.2", + "zerocopy", ] [[package]] @@ -1546,6 +1563,12 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cbindgen" version = "0.29.2" @@ -1629,6 +1652,33 @@ dependencies = [ "windows-link", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "clang-sys" version = "1.8.1" @@ -1798,12 +1848,73 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "is-terminal", + "itertools 0.10.5", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + [[package]] name = "crypto-common" version = "0.2.1" @@ -2394,6 +2505,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -2421,6 +2543,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + [[package]] name = "home" version = "0.5.12" @@ -2774,12 +2902,32 @@ dependencies = [ "serde", ] +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.13.0" @@ -3244,6 +3392,12 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + [[package]] name = "openssl-probe" version = "0.2.1" @@ -3466,6 +3620,34 @@ version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] + [[package]] name = "potential_utf" version = "0.1.5" @@ -3847,6 +4029,26 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.5.18" @@ -3899,6 +4101,12 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-lite" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973" + [[package]] name = "regex-syntax" version = "0.8.10" @@ -4814,6 +5022,16 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.11.0" diff --git a/Cargo.toml b/Cargo.toml index 7254a3035..fa5a0527b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ members = [ "bd-bounded-buffer", "bd-buffer", "bd-client-common", + "bd-client-regex", "bd-client-stats", "bd-client-stats-store", "bd-completion", @@ -84,6 +85,7 @@ cc = "1.2.60" clap = { version = "4.6.1", features = ["derive", "env"] } cmake = "0.1.58" color-backtrace = "0.7.2" +criterion = { version = "0.5", features = ["html_reports"] } concat-string = "1.0.1" crc32fast = "1.5.0" ctor = "0.10.0" diff --git a/bd-client-regex/Cargo.toml b/bd-client-regex/Cargo.toml new file mode 100644 index 000000000..795d8ed50 --- /dev/null +++ b/bd-client-regex/Cargo.toml @@ -0,0 +1,21 @@ +[package] +edition = "2024" +license-file = "../LICENSE" +name = "bd-client-regex" +publish = false +version = "1.0.0" + +[lib] +doctest = false + +[dependencies] +bd-workspace-hack.workspace = true +regex-lite = "0.1.6" + +[dev-dependencies] +criterion.workspace = true +regex = "1.12.3" + +[[bench]] +harness = false +name = "regex_comparison" diff --git a/bd-client-regex/benches/regex_comparison.rs b/bd-client-regex/benches/regex_comparison.rs new file mode 100644 index 000000000..dda1a282d --- /dev/null +++ b/bd-client-regex/benches/regex_comparison.rs @@ -0,0 +1,173 @@ +// shared-core - bitdrift's common client/server libraries +// Copyright Bitdrift, Inc. All rights reserved. +// +// Use of this source code is governed by a source available license that can be found in the +// LICENSE file or at: +// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt + +// Compares regex-lite (used by bd-client-regex) against full regex to quantify the perf +// trade-off for binary size savings. +// +// Run with: cargo bench -p bd-client-regex + +use criterion::{Criterion, black_box, criterion_group, criterion_main}; + +// Patterns representative of real workflow/matcher usage. +const PATTERNS: &[(&str, &str)] = &[ + ("catch_all", ".*"), + ("prefix", "^HTTPRequest.*"), + ("error_code", r"error_code=\d+"), + ("url_path", r"^/api/v\d+/[a-zA-Z]+"), + ("log_level", r"^(DEBUG|INFO|WARNING|ERROR):\s"), + ("json_field", r#""session_id"\s*:\s*"[a-f0-9-]+""#), +]; + +// Haystacks representative of real log messages and field values. +const HAYSTACKS: &[(&str, &str)] = &[ + ("short_match", "HTTPRequest GET /api/v1/users"), + ("short_miss", "SceneDidActivate"), + ( + "medium_log", + "ERROR: connection timeout after 30s for host api.example.com:443 error_code=504", + ), + ( + "json_payload", + r#"{"session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "event": "app_launch"}"#, + ), +]; + +fn bench_compile(c: &mut Criterion) { + let mut group = c.benchmark_group("compile"); + group.sample_size(20); + for &(name, pattern) in PATTERNS { + group.bench_function(format!("lite/{name}"), |b| { + b.iter(|| regex_lite::Regex::new(black_box(pattern)).unwrap()); + }); + group.bench_function(format!("full/{name}"), |b| { + b.iter(|| regex::Regex::new(black_box(pattern)).unwrap()); + }); + } + group.finish(); +} + +fn bench_is_match(c: &mut Criterion) { + let mut group = c.benchmark_group("is_match"); + group.sample_size(20); + for &(pat_name, pattern) in PATTERNS { + let lite_re = regex_lite::Regex::new(pattern).unwrap(); + let full_re = regex::Regex::new(pattern).unwrap(); + + for &(hay_name, haystack) in HAYSTACKS { + let id = format!("{pat_name}/{hay_name}"); + group.bench_function(format!("lite/{id}"), |b| { + b.iter(|| lite_re.is_match(black_box(haystack))); + }); + group.bench_function(format!("full/{id}"), |b| { + b.iter(|| full_re.is_match(black_box(haystack))); + }); + } + } + group.finish(); +} + +fn bench_captures(c: &mut Criterion) { + let mut group = c.benchmark_group("captures"); + group.sample_size(20); + + // Simulates save_field regex capture extraction (bd-workflows/src/config.rs). + let capture_patterns: &[(&str, &str, &str)] = &[ + ( + "error_code", + r"error_code=(\d+)", + "ERROR: connection timeout error_code=504", + ), + ( + "session_id", + r#""session_id"\s*:\s*"([a-f0-9-]+)""#, + r#"{"session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"}"#, + ), + ( + "version", + r"^v(\d+)\.(\d+)\.(\d+)", + "v2.14.3-beta+build.123", + ), + ]; + + for &(name, pattern, haystack) in capture_patterns { + let lite_re = regex_lite::Regex::new(pattern).unwrap(); + let full_re = regex::Regex::new(pattern).unwrap(); + + group.bench_function(format!("lite/{name}"), |b| { + b.iter(|| lite_re.captures(black_box(haystack))); + }); + group.bench_function(format!("full/{name}"), |b| { + b.iter(|| full_re.captures(black_box(haystack))); + }); + } + group.finish(); +} + +fn bench_replace_all(c: &mut Criterion) { + let mut group = c.benchmark_group("replace_all"); + group.sample_size(20); + + // Simulates log filter regex substitution (bd-log-filter/src/lib.rs). + let replace_cases: &[(&str, &str, &str, &str)] = &[ + ( + "redact_email", + r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}", + "User user@example.com logged in from admin@corp.io", + "[REDACTED]", + ), + ( + "mask_token", + r"Bearer [a-zA-Z0-9._-]+", + "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.payload.signature", + "Bearer [MASKED]", + ), + ]; + + for &(name, pattern, haystack, replacement) in replace_cases { + let lite_re = regex_lite::Regex::new(pattern).unwrap(); + let full_re = regex::Regex::new(pattern).unwrap(); + + group.bench_function(format!("lite/{name}"), |b| { + b.iter(|| lite_re.replace_all(black_box(haystack), replacement)); + }); + group.bench_function(format!("full/{name}"), |b| { + b.iter(|| full_re.replace_all(black_box(haystack), replacement)); + }); + } + group.finish(); +} + +fn bench_escape(c: &mut Criterion) { + let mut group = c.benchmark_group("escape"); + group.sample_size(20); + + // Simulates PREFIX match compilation (bd-log-matcher/src/matcher.rs). + let values = &[ + ("simple", "HTTPRequest"), + ("special_chars", "foo.bar[0]+baz"), + ]; + + for &(name, value) in values { + group.bench_function(format!("lite/{name}"), |b| { + b.iter(|| regex_lite::escape(black_box(value))); + }); + group.bench_function(format!("full/{name}"), |b| { + b.iter(|| regex::escape(black_box(value))); + }); + } + group.finish(); +} + +criterion_group!( + benches, + bench_compile, + bench_is_match, + bench_captures, + bench_replace_all, + bench_escape, +); +criterion_main!(benches); diff --git a/bd-client-regex/src/lib.rs b/bd-client-regex/src/lib.rs new file mode 100644 index 000000000..aee6a2dfb --- /dev/null +++ b/bd-client-regex/src/lib.rs @@ -0,0 +1,8 @@ +// shared-core - bitdrift's common client/server libraries +// Copyright Bitdrift, Inc. All rights reserved. +// +// Use of this source code is governed by a source available license that can be found in the +// LICENSE file or at: +// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt + +pub use regex_lite::{Error, Regex, escape}; diff --git a/bd-crash-handler/Cargo.toml b/bd-crash-handler/Cargo.toml index ee79d78b8..410061f22 100644 --- a/bd-crash-handler/Cargo.toml +++ b/bd-crash-handler/Cargo.toml @@ -33,7 +33,7 @@ log.workspace = true memmap2.workspace = true mockall.workspace = true notify.workspace = true -regex.workspace = true +bd-client-regex.path = "../bd-client-regex" thiserror.workspace = true time.workspace = true tokio.workspace = true diff --git a/bd-log-filter/Cargo.toml b/bd-log-filter/Cargo.toml index fa729771a..a9220f6ae 100644 --- a/bd-log-filter/Cargo.toml +++ b/bd-log-filter/Cargo.toml @@ -18,7 +18,7 @@ bd-state.path = "../bd-state" bd-workspace-hack.workspace = true itertools.workspace = true log.workspace = true -regex.workspace = true +bd-client-regex.path = "../bd-client-regex" time.workspace = true [dev-dependencies] diff --git a/bd-log-filter/src/lib.rs b/bd-log-filter/src/lib.rs index b7fd017dd..fd44dd62f 100644 --- a/bd-log-filter/src/lib.rs +++ b/bd-log-filter/src/lib.rs @@ -19,6 +19,7 @@ mod filter_chain_test; use anyhow::{Context, Result, anyhow}; +use bd_client_regex::Regex; use bd_log_primitives::tiny_set::TinyMap; use bd_log_primitives::{ FieldsRef, @@ -34,7 +35,6 @@ use bd_proto::protos::filter::filter::filter::{self}; use bd_proto::protos::filter::filter::{Filter as FilterProto, FiltersConfiguration}; use filter::transform::Transform_type; use itertools::Itertools; -use regex::Regex; use std::borrow::Cow; #[cfg(test)] diff --git a/bd-log-matcher/Cargo.toml b/bd-log-matcher/Cargo.toml index 6f3eedfa2..dc8f71dc3 100644 --- a/bd-log-matcher/Cargo.toml +++ b/bd-log-matcher/Cargo.toml @@ -18,7 +18,7 @@ bd-workspace-hack.workspace = true itertools.workspace = true protobuf.workspace = true rand.workspace = true -regex.workspace = true +bd-client-regex.path = "../bd-client-regex" tempfile.workspace = true diff --git a/bd-log-matcher/src/matcher.rs b/bd-log-matcher/src/matcher.rs index 8566346ac..182aaba34 100644 --- a/bd-log-matcher/src/matcher.rs +++ b/bd-log-matcher/src/matcher.rs @@ -454,7 +454,7 @@ impl Leaf { (value.to_string(), Operator::OPERATOR_EQUALS) }, legacy_log_matcher::base_log_matcher::StringMatchType::PREFIX => ( - format!("^{}.*", regex::escape(value)), + format!("^{}.*", bd_client_regex::escape(value)), Operator::OPERATOR_REGEX, ), legacy_log_matcher::base_log_matcher::StringMatchType::REGEX => { diff --git a/bd-log-matcher/src/value_matcher.rs b/bd-log-matcher/src/value_matcher.rs index 0cd36bb21..a3aeeae82 100644 --- a/bd-log-matcher/src/value_matcher.rs +++ b/bd-log-matcher/src/value_matcher.rs @@ -6,6 +6,7 @@ // https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt use anyhow::{Result, anyhow}; +use bd_client_regex::Regex; use bd_log_primitives::tiny_set::TinyMap; use bd_proto::protos::value_matcher::value_matcher::double_value_match::Double_value_match_type; use bd_proto::protos::value_matcher::value_matcher::int_value_match::Int_value_match_type; @@ -16,7 +17,6 @@ use bd_proto::protos::value_matcher::value_matcher::{ StringValueMatch as StringValueMatch_type, }; use protobuf::EnumOrUnknown; -use regex::Regex; use std::ops::Deref; // diff --git a/bd-log-matcher/src/version.rs b/bd-log-matcher/src/version.rs index 47bce772c..256f55aa6 100644 --- a/bd-log-matcher/src/version.rs +++ b/bd-log-matcher/src/version.rs @@ -10,10 +10,10 @@ mod test; use anyhow::{Result, anyhow}; +use bd_client_regex::Regex; use bd_proto::protos::value_matcher::value_matcher::{Operator, SemVerValueMatch}; use itertools::Itertools; use protobuf::EnumOrUnknown; -use regex::Regex; use std::cmp::Ordering; use std::fmt::Display; diff --git a/bd-workflows/Cargo.toml b/bd-workflows/Cargo.toml index 6a743ecd9..5d741d7ff 100644 --- a/bd-workflows/Cargo.toml +++ b/bd-workflows/Cargo.toml @@ -34,7 +34,7 @@ bincode.workspace = true itertools.workspace = true log.workspace = true protobuf.workspace = true -regex.workspace = true +bd-client-regex.path = "../bd-client-regex" serde.workspace = true sha2.workspace = true thiserror.workspace = true diff --git a/bd-workflows/src/config.rs b/bd-workflows/src/config.rs index 144ff29c3..c233c4aa7 100644 --- a/bd-workflows/src/config.rs +++ b/bd-workflows/src/config.rs @@ -7,6 +7,7 @@ use crate::workflow::Traversal; use anyhow::{anyhow, bail}; +use bd_client_regex::Regex; use bd_log_matcher::matcher::Tree; use bd_log_primitives::{FieldsRef, LogMessage}; use bd_proto::protos::workflow::save_field::SaveField; @@ -22,7 +23,6 @@ use bd_proto::protos::workflow::workflow::workflow::{ use bd_state::Scope; use bd_stats_common::MetricType; use protobuf::MessageField; -use regex::Regex; use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet, HashMap}; use time::Duration; @@ -605,7 +605,7 @@ impl Transition { required_matches: rule.count, }, Rule_type::RuleStateChangeMatch(rule) => Predicate::StateChangeMatch { - state_change_match: StateChangeMatch::try_from_proto(rule)?, + state_change_match: Box::new(StateChangeMatch::try_from_proto(rule)?), extra_matcher: rule.log_matcher.as_ref().map(Tree::new).transpose()?, }, }; @@ -684,7 +684,7 @@ pub(crate) enum Predicate { required_matches: u32, }, StateChangeMatch { - state_change_match: StateChangeMatch, + state_change_match: Box, extra_matcher: Option, }, } diff --git a/bd-workspace-hack/Cargo.toml b/bd-workspace-hack/Cargo.toml index 6bb831070..f9bd16f31 100644 --- a/bd-workspace-hack/Cargo.toml +++ b/bd-workspace-hack/Cargo.toml @@ -51,6 +51,7 @@ tokio-util = { version = "0.7", features = ["codec", "io", "time"] } tower = { version = "0.5", default-features = false, features = ["balance", "buffer", "limit", "load-shed", "log", "retry"] } tracing = { version = "0.1", features = ["log"] } tracing-core = { version = "0.1" } +zerocopy = { version = "0.8", default-features = false, features = ["derive", "simd"] } [build-dependencies] bitflags = { version = "2", default-features = false, features = ["std"] } @@ -90,6 +91,7 @@ tower = { version = "0.5", default-features = false, features = ["balance", "buf tracing = { version = "0.1", features = ["log"] } tracing-core = { version = "0.1" } winnow = { version = "1" } +zerocopy = { version = "0.8", default-features = false, features = ["derive", "simd"] } [target.aarch64-apple-darwin.dependencies] errno = { version = "0.3" }