From 1aad99fdee50b8fb2ada4b3da11d64012fa989f7 Mon Sep 17 00:00:00 2001 From: ppom Date: Fri, 10 Oct 2025 12:00:00 +0200 Subject: [PATCH] `cargo build` builds plugin And benchmark for virtual plugin --- Cargo.toml | 4 ++ bench/bench.sh | 2 +- bench/small-heavy-load-virtual.yml | 86 ++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 bench/small-heavy-load-virtual.yml diff --git a/Cargo.toml b/Cargo.toml index 6e953a6..926b3b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,3 +80,7 @@ members = ["plugins/reaction-plugin", "plugins/reaction-plugin-virtual"] remoc = { version = "0.18.3" } serde = { version = "1.0.203", features = ["derive"] } tokio = { version = "1.40.0" } + +[[bin]] +name = "reaction-plugin-virtual" +path = "plugins/reaction-plugin-virtual/src/main.rs" diff --git a/bench/bench.sh b/bench/bench.sh index 59d4894..9f42ec2 100755 --- a/bench/bench.sh +++ b/bench/bench.sh @@ -14,7 +14,7 @@ then fi rm -f reaction.db -cargo build --release +cargo build --release --bins sudo systemd-run --wait \ -p User="$(id -nu)" \ -p MemoryAccounting=yes \ diff --git a/bench/small-heavy-load-virtual.yml b/bench/small-heavy-load-virtual.yml new file mode 100644 index 0000000..0f074b9 --- /dev/null +++ b/bench/small-heavy-load-virtual.yml @@ -0,0 +1,86 @@ +--- +# This configuration permits to test reaction's performance +# under a very high load +# +# It keeps regexes super simple, to avoid benchmarking the `regex` crate, +# and benchmark reaction's internals instead. +concurrency: 32 + +plugins: + - path: "/home/ppom/prg/reaction/target/release/reaction-plugin-virtual" + +patterns: + num: + regex: '[0-9]{3}' + ip: + regex: '(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:[0-9a-fA-F:]{2,90})' + ignore: + - 1.0.0.1 + +streams: + virtual: + type: virtual + filters: + find0: + regex: + - '^$' + actions: + damn: + cmd: [ 'sleep', '0.0' ] + undamn: + cmd: [ 'sleep', '0.0' ] + after: 1m + onexit: false + tailDown1: + cmd: [ 'sh', '-c', 'sleep 2; seq 1001 | while read i; do echo found $i; done' ] + filters: + find1: + regex: + - '^found ' + retry: 9 + retryperiod: 6m + actions: + virtual: + type: virtual + options: + send: '' + to: virtual + tailDown2: + cmd: [ 'sh', '-c', 'sleep 2; seq 100100 | while read i; do echo found $i; echo trouvé $i; done' ] + filters: + find2: + regex: + - '^found ' + retry: 480 + retryperiod: 6m + actions: + virtual: + type: virtual + options: + send: '' + to: virtual + tailDown3: + cmd: [ 'sh', '-c', 'sleep 2; seq 100100 | while read i; do echo found $i; echo trouvé $i; done' ] + filters: + find3: + regex: + - '^found ' + retry: 480 + retryperiod: 6m + actions: + virtual: + type: virtual + options: + send: '' + to: virtual + find4: + regex: + - '^trouvé ' + retry: 480 + retryperiod: 6m + actions: + virtual: + type: virtual + options: + send: '' + to: virtual