Skip to main content

Module runtime_util

Module runtime_util 

Source
Expand description

Tokio runtime builders (budgeted multi-thread workers for CDP + HTTP fan-out). Tokio runtime builders tuned for one-shot CLI with bounded parallelism.

§Workload

Mista / I/O-bound (Chrome CDP + HTTP). Async coordinates wait; CPU work uses Rayon or spawn_blocking (see crate::concurrency).

§Product latency model

Wall time is dominated by Chrome CDP / network I/O, not Rust CPU. Rules rules_rust_latencia_reduzir + rules_rust_paralelismo require:

  • Bounded runtimes — worker count from crate::concurrency::browser_worker_threads (not unbounded num_cpus on a one-shot agent process; hard-capped at 8).
  • No blocking work on async workers without spawn_blocking.
  • No PGO/BOLT/isolcpus/mlockall as product defaults (daemon/HFT ops; product law is BORN→EXECUTE→FINALIZE→DIE).

§Latency budgets (agent-facing, host-local, release build)

PathP99 budget (order of magnitude)Notes
Clap parse + doctor offline quick50 msNo Chrome; meta path
--help cold80 msFirst process image load
JSON envelope encode (small)100 µsCriterion / unit
Chrome launch + first CDPsecondsExternal; not Rust hot path

Budgets are ceilings for regression detection, not SLOs for trading. Re-measure with scripts/latency-baseline.sh after runtime changes.

§Runtime flavours

HelperFlavourUse
block_on_browser_timeoutmulti-thread, budgeted workersCDP event fan-out
[block_on_io]multi-thread, budgeted (I/O pipelines)HTTP scrape / batch / crawl

Never create an unbounded new_multi_thread() without the concurrency budget.

Constants§

BROWSER_THREAD_NAME
Thread name prefix for browser runtime workers (bac-browser-0, …).
IO_THREAD_NAME
Thread name prefix for I/O multi-thread runtimes.

Functions§

block_on_io
Drive an async I/O future to completion on a budgeted multi-thread runtime.
build_browser_runtime
Build the multi-thread runtime used for Chrome CDP sessions.
build_io_runtime
Build a multi-thread runtime for HTTP / offline async fan-out.