Skip to main content

Crate matier_pool

Crate matier_pool 

Source
Expand description

matier-pool: per-origin connection pooling for Matier (PLAN §6).

  • Origin map: a papaya lock-free hash map OriginKey -> Arc<OriginPool>. Lookups are read-mostly (one insert per origin ever), papaya reads take no lock and never write shared cache lines beyond the epoch guard, and the lookup is allocation-free (borrowed key, FxHash).
  • HTTP/1: LIFO idle stack behind a short parking_lot::Mutex (push/pop only, never held across an await), a connection count, and a FIFO waiter queue (slab-backed linked list, O(1) cancel) with direct handoff of released connections (or of a freed dial slot) to the oldest waiter. The liveness probe runs at checkout; the idle timeout is checked lazily.
  • HTTP/2: an arc_swap snapshot of handles, power-of-two-choices on in_flight, try_reserve, coalesced background dials, and zero-config load-based autoscaling (scale).

The protocol of an origin is learned from the first connection (ALPN / prior knowledge) and cached; concurrent first requests wait for that one connection instead of dialing in parallel.

Modules§

scale
HTTP/2 connection autoscaling policy: thresholds and the pure decision functions (unit tested).

Structs§

OriginStats
Snapshot of one origin’s pool, for diagnostics and tests.
Pool
The connection pool. Cheap to clone.
PoolConfig
Pool limits and timeouts.