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 unboundednum_cpuson 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)
| Path | P99 budget (order of magnitude) | Notes |
|---|---|---|
| Clap parse + doctor offline quick | ≤ 50 ms | No Chrome; meta path |
--help cold | ≤ 80 ms | First process image load |
| JSON envelope encode (small) | ≤ 100 µs | Criterion / unit |
| Chrome launch + first CDP | seconds | External; 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
| Helper | Flavour | Use |
|---|---|---|
block_on_browser_timeout | multi-thread, budgeted workers | CDP 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.