Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/holger

bench-scenarios/examples/pip_probe.rs

//! Local probe for the holger-ds **Python journey** heavy arm: build a modest
//! synthetic wheel corpus, serve it over the real Holger HTTP gateway as a PEP 503
//! index, and bombard it over the protocol — printing the same numbers the
//! `holger.pip_index_serve` bench arm records. This is the fast dev-box readout
//! (Loki produces the authoritative heavy sweep).
//!
//! Run: `cargo run -p holger-bench-scenarios --example pip_probe --features served`
//!   env: `PIP_PROBE_MB` (corpus MiB, default 48), `PIP_PROBE_SECS` (default 4).

use std::time::Duration;

use holger_bench_scenarios::{build_pip_corpus, cores, served};

#[tokio::main(flavor = "multi_thread")]
async fn main() -> anyhow::Result<()> {
    let mb: u64 = std::env::var("PIP_PROBE_MB")
        .ok()
        .and_then(|s| s.parse().ok())
        .unwrap_or(48);
    let secs: u64 = std::env::var("PIP_PROBE_SECS")
        .ok()
        .and_then(|s| s.parse().ok())
        .unwrap_or(4);
    let dir = std::env::temp_dir().join("holger-ds-pip-probe");
    let _ = std::fs::remove_dir_all(&dir);

    eprintln!("[probe] building {mb} MiB synthetic wheel corpus …");
    let (archive, packages) = build_pip_corpus(&dir, mb * 1024 * 1024)?;
    let concurrency = cores();
    eprintln!("[probe] {packages} wheels; bombarding {secs}s @ concurrency {concurrency} …");

    let o = served::run_pip_index_fetch(
        &archive,
        "pip",
        None,
        concurrency,
        Duration::from_secs(secs),
    )
    .await?;

    println!(
        "holger.pip_index_serve (local probe, {mb} MiB corpus, {secs}s, {concurrency} threads)"
    );
    println!("  packages                        : {}", o.packages);
    println!("  wheel files                     : {}", o.files);
    println!("  holger_served_mbs               : {:.1}", o.wheel.mbs);
    println!(
        "  ops_per_sec (wheel download)    : {:.0}",
        o.wheel.ops_per_sec
    );
    println!(
        "  wheel p50/p99 ms                : {:.3} / {:.3}",
        o.wheel.p50_ms, o.wheel.p99_ms
    );
    println!(
        "  holger_index_ops_per_sec        : {:.0}",
        o.index.ops_per_sec
    );
    println!(
        "  holger_inprocess_read_ceiling   : {:.1} MB/s",
        o.inprocess_ceiling_mbs
    );
    println!(
        "  wheel ok_ops / ops              : {} / {}",
        o.wheel.ok_ops, o.wheel.ops
    );

    let _ = std::fs::remove_dir_all(&dir);
    Ok(())
}