Skip to main content

start_high_perf_multi_thread

Function start_high_perf_multi_thread 

Source
pub fn start_high_perf_multi_thread(
    server: Server,
    limits: PerfLimits,
    worker_threads: Option<usize>,
) -> Result<(), ServerError>
Available on crate features high-perf and high-perf-multi-thread only.
Expand description

Synchronous entry point that builds a multi-threaded Tokio runtime and runs start_high_perf on it. Use this on multi-core hosts when start_high_perf called from a current_thread runtime is leaving cores idle — bombardier load tests showed sync Server::start outperforming the async path 3× under 256-connection keep-alive purely because the async path was funneling all connections through one OS thread.

worker_threads = None lets Tokio pick (defaults to logical CPU count). Pass Some(n) to pin the worker count for reproducible benchmarking or container CPU limits.

Owning the runtime internally means callers don’t need to add rt-multi-thread to their tokio features list and don’t need to reason about runtime flavour mismatches between the bind site and the accept loop.

§Examples

use http_handle::Server;
use http_handle::perf_server::{start_high_perf_multi_thread, PerfLimits};

let server = Server::new("127.0.0.1:8080", ".");
// Default worker count (one per logical core).
let _ = start_high_perf_multi_thread(server, PerfLimits::default(), None);

§Errors

Returns an error when the multi-thread runtime cannot be built or the underlying start_high_perf accept loop fails.

§Panics

This function does not panic.