lietzsche;stokes

updated 2026-11-26·4 min read

Verification Latency & Memory Benchmarks

What Cloudflame's Criterion suites and the Stokes test harness actually measured, without extrapolated CLI numbers.

There are two completely different things people lump together under “benchmarks” here: how fast the Python CLI checks a repo, and how fast the Rust cloudflame-proxy testbed processes packet descriptors.

I didn’t build a Criterion harness around a 50k LOC Python CLI run, and pretending otherwise would be fake. What is verified in the repo is simpler: the CLI skips Docker and full compiler invocations (rustc, mypy), so local checks finish quickly, while the actual Criterion numbers live inside the Rust cloudflame-proxy crate.

Stokes benchmarks view comparing static AST contract checks against monolingual linters and Docker testcontainers
stokes benchmarks overview: static ast checks vs. full compiler runs and docker suites.

What Criterion Actually Measured (cloudflame-proxy)

Two sets of Rust Criterion measurements sit in the repo, and they measure two different slices of the intake path:

  1. 16-Item Slice Partitioning (ingest_benchmark.rs): in_place_select_nth_boundary_16 partitions a 16-item stack window with select_nth_unstable_by in 7.66 ns (0 B heap), versus 29.74 ns for heap_allocated_vec_boundary_16 (Vec::with_capacity + sort_by + truncate). stokes/harness/criterion_runner.py also stores 7.66 and 29.74 as its offline reference constants when Criterion JSON files aren’t on disk.
  2. Full-Struct Deserialization (CONFORMANCE.md): Before adding Dual-Zone in-place partitioning, bounded stack deserialization on the full struct measured 213.09 ns versus 134.19 ns for heap Vec<Feature> reallocation (0.6x faster, i.e., actually slower on raw deserialization speed, trading raw throughput for 0 B heap allocation).
Benchmark CaseSourceStack / In-PlaceHeap Vec BaselineWhat It Measures
in_place_select_nth_boundary_16ingest_benchmark.rs7.66 ns (0 B heap)29.74 nsPartitioning a 16-item L1-resident window (select_nth_unstable_by)
Bounded Stack DeserializationCONFORMANCE.md213.09 ns (0 B heap)134.19 nsFull struct deserialization (0.6x slower than heap, zero allocs)

Test Harness & Fuzz Measurements

Why Zero Heap Allocation Matters at the L7 Edge

  1. L1D Cache Line Residency

    FeatureDescriptor is 8 bytes (repr(C, align(8))). 200 descriptors occupy 1,600 bytes across 25 contiguous 64-byte cache lines (4.8% of a 32 KB L1D cache) without pointer indirection.

  2. Dual-Zone In-Place Partitioning

    Downstream proxies pin 128 core rules in Zone 0 (priority >= 200) and partition 72 adaptive slots in Zone 1 via select_nth_unstable_by with 0 B heap overhead.

  3. 10,000-Case Float Fuzz Battery

    float_fuzz_battery.py sweeps 10,000 randomized 32-bit patterns plus adversarial NaNs, infinities, and subnormals to verify fail-secure clamping to 100.0.

  4. Normalized Semantic AST Lockfile

    stokes.lock hashes canonical schema signatures, skipping comments and formatting while catching real cardinality drift.

ingest_benchmark.rs (16-Item & 200-Item Criterion Functions)
// cloudflame/crates/cloudflame-proxy/benches/ingest_benchmark.rs
group.bench_function("in_place_select_nth_boundary_16", |b| {
    let mut window = [FeatureDescriptor::new(0, 0, false); 16];
    window.copy_from_slice(&sample[184..200]);
    b.iter(|| {
        window.select_nth_unstable_by(7, |a, b| b.priority.cmp(&a.priority));
        black_box(&window[..8]);
    });
});

group.bench_function("heap_allocated_vec_boundary_16", |b| {
    b.iter(|| {
        let mut heap_vec: Vec<FeatureDescriptor> = Vec::with_capacity(16);
        heap_vec.extend_from_slice(&sample[184..200]);
        heap_vec.sort_by(|a, b| b.priority.cmp(&a.priority));
        heap_vec.truncate(8);
        black_box(heap_vec);
    });
});
Benchmarking & Memory FAQ
  • Why not print a per-phase millisecond table for the CLI? Because I didn’t run a formal multi-phase profiler on a 50k LOC monorepo, and guessing sub-millisecond phase splits would be meaningless. Skipping Docker and rustc is why the CLI feels instant locally.
  • Why does 7.66 ns only cover 16 items? That is what in_place_select_nth_boundary_16 in ingest_benchmark.rs actually benchmarks; full-struct deserialization in CONFORMANCE.md ran at 213.09 ns.
  • Why does 32 KB L1D cache residency matter? Keeping the 1,600-byte descriptor array inside 25 contiguous 64-byte cache lines avoids pointer chasing on packet intake.
  • What does the 10,000-case float fuzz battery verify? Adversarial IEEE-754 floats, subnormals, quiet and signaling NaNs, and infinities against sanitize_signal_float.

See Verification, Fuzzing & Simulation Harness and Cloudflame Case Study for the full incident setup.

Search wiki and portfolio

type to search across all entries.