Skip to content

bench(eval): add rule_load comparison across load entry points#122

Merged
mostafa merged 1 commit into
mainfrom
bench/rule-load
May 16, 2026
Merged

bench(eval): add rule_load comparison across load entry points#122
mostafa merged 1 commit into
mainfrom
bench/rule-load

Conversation

@mostafa
Copy link
Copy Markdown
Member

@mostafa mostafa commented May 16, 2026

Summary

Adds a Criterion benchmark group rule_load that compares the three rule-load entry points on Engine at 1K / 10K / 100K rules and records the numbers in BENCHMARKS.md under a new "Rule Load Paths (0.11.x)" subsection.

The benchmark exists to give empirical confirmation that all three paths scale linearly in the rule count after PR #121 made the single-rule add_rule amortized O(1). The existing functional regression test (test_add_rule_loop_scales_linearly_on_large_corpus) already guards against quadratic reintroduction; this PR is the matching numerical evidence.

Results

M4 Pro, release build, 2026-05-16. Median time from Criterion, 10 samples per benchmark.

Rules add_collection add_rules add_rule loop
1,000 1.15 ms (1.15 us/rule) 1.17 ms (1.17 us/rule) 1.64 ms (1.64 us/rule)
10,000 11.82 ms (1.18 us/rule) 11.85 ms (1.18 us/rule) 17.23 ms (1.72 us/rule)
100,000 121.65 ms (1.22 us/rule) 122.13 ms (1.22 us/rule) 166.07 ms (1.66 us/rule)

Per-rule cost stays flat from 1K to 100K across all three paths, confirming O(N) total complexity. The single-rule loop costs roughly 40% more per rule than the batched paths, which is the amortized overhead of the incremental insert plus the doubling-watermark bloom rebuilds along the way. No quadratic blowup.

Changes

  • New bench_rule_load group in crates/rsigma-eval/benches/eval.rs, wired into both daachorse-index and default criterion_group! macros.
  • New "Rule Load Paths (0.11.x)" subsection in BENCHMARKS.md, inserted between "Rule Compilation" and "Single Event Evaluation".

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo bench -p rsigma-eval --bench eval -- rule_load

Adds a Criterion benchmark group `rule_load` that compares the three
public rule-load APIs at 1K / 10K / 100K rules:

- `Engine::add_collection` (batched, single rebuild)
- `Engine::add_rules` (batched with per-rule error collection, single
  rebuild)
- `Engine::add_rule` in a loop (now amortized O(1) per call via the
  incremental `RuleIndex::append_rule` and doubling-amortized
  `FieldBloomIndex`)

Records the numbers in `BENCHMARKS.md` under a new "Rule Load Paths
(0.11.x)" subsection. All three paths scale linearly in the rule
count; the single-rule loop is roughly 40% slower than batched due to
incremental insert overhead plus the doubling-watermark rebuilds
between 1 and 100K rules, with no quadratic blowup. Pinned numbers on
M4 Pro, release build:

| Rules   | add_collection | add_rules | add_rule loop |
|--------:|---------------:|----------:|--------------:|
| 1,000   |        1.15 ms |   1.17 ms |       1.64 ms |
| 10,000  |       11.82 ms |  11.85 ms |      17.23 ms |
| 100,000 |      121.65 ms | 122.13 ms |     166.07 ms |

Run with `cargo bench -p rsigma-eval --bench eval -- rule_load`.
@mostafa mostafa merged commit 02779ac into main May 16, 2026
10 checks passed
@mostafa mostafa deleted the bench/rule-load branch May 16, 2026 18:15
SecurityEnthusiast pushed a commit to SecurityEnthusiast/rsigma that referenced this pull request May 17, 2026
Replaces the placeholder Unreleased section with a full release-notes
draft following the format of the v0.11.0 / v0.10.0 / v0.9.0 entries.
Covers every PR merged to main since v0.11.0:

- Daemon and CLI observability (PR timescale#107) - tower-http access logs,
  per-request OTLP tracing, batch spans, source resolution spans, DLQ
  visibility, NATS/sink lifecycle, correlation eviction warnings, rule
  load diagnostics, daemon lifecycle, global `--log-format` flag.
- Eval rule loading performance (PRs timescale#119, timescale#121, timescale#122, timescale#123) - batched
  loaders rebuild indexes once per batch via `Engine::add_rules` /
  `extend_compiled_rules` / `add_collection`; single-rule path
  amortized O(1) via `RuleIndex::append_rule` and a doubling-watermark
  `FieldBloomIndex`. SigmaHQ corpus (~3,120 rules) now loads in ~120 ms.
- CLI command groups (PR timescale#124) - the noun-led `engine` / `rule` /
  `backend` / `pipeline` / `attack` grouping with the existing
  migration table preserved verbatim.
- Test reliability (PRs timescale#115, timescale#123) - cli_daemon_http and
  cli_daemon_otlp E2E suites de-flaked on macOS under load; eval bloom
  test made deterministic against random AHash seeds.
- Dependency and CI bumps.

All command-name references within the draft already use the new
noun-led paths (`engine eval`, `rule validate`, etc.) so the next
release ships with consistent terminology throughout the notes.
@mostafa mostafa mentioned this pull request May 19, 2026
5 tasks
SecurityEnthusiast pushed a commit to SecurityEnthusiast/rsigma that referenced this pull request May 20, 2026
The "operability, performance, and documentation" release.

* Workspace bumped 0.11.0 -> 0.12.0; all 10 inter-crate dep pins
  refreshed; Cargo.lock regenerated under --locked.
* CHANGELOG.md [Unreleased] section flipped to [0.12.0] - 2026-05-19;
  comparison link updated to v0.11.0...v0.12.0; tag reference added
  to the bottom-of-file link block.
* CHANGELOG also gained a Documentation site (PR timescale#129) section under
  the existing observability / eval-perf / CLI-groups / test-reliability
  / dependencies headings, and the TL;DR theme moved from "operations
  and load performance" to "operability, performance, and documentation"
  to reflect the new docs site as a top-line deliverable.

Covers all 13 PRs merged since v0.11.0: timescale#107 (observability),
timescale#111/timescale#113/timescale#114/timescale#120 (dependency batches), timescale#115/timescale#123 (test
reliability), timescale#119/timescale#121/timescale#122/timescale#123 (eval rule loading perf), timescale#124
(CLI command groups), timescale#127 (CLI docs followup), timescale#129 (documentation
site).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant