HomeDocs-Technical WhitePaper07-EFT.WP.Core.Threads v1.0

Chapter 3 — Message Channels and Backpressure


I. Scope and Objectives


II. Channel Model and Message Format

  1. Channel shape
    • chan = {name, mode, cap, policy, metrics}, where mode ∈ {"spsc","mpsc","spmc","mpmc"}.
    • Queue state: q_len(t), cap, age_head(t), blocked_put/blocked_get.
  2. Message minimal fields
    • msg = {eid, ts, tau_mono, idemp_key?, sem, ttl?, deadline?, payload_ref, trace_ctx?}.
    • Delivery semantics sem ∈ {"at_most_once","at_least_once","exactly_once*"} (*best-effort via deduplication).

III. Steady State and Queue Metrics (S73 Series)

  1. Core definitions and identities
    • Utilization: rho = lambda / mu; steady-state necessary condition: rho < 1.
    • Little’s Law: L = lambda * W; queue form: L_q = lambda * W_q.
  2. Approximate formulas (M/M/1)
    • S73-1: W_q approx rho / ( mu * (1 - rho) ).
    • S73-2: W approx 1 / ( mu - lambda ).
  3. Batching correction
    With batch size b >= 1, effective service rate mu_eff approx mu * b; equivalent queue length q_len_eff = ceil( q_len / b ).

IV. Postulates and Constraints (P73-*)


V. Backpressure Signals and Control Functions

  1. Backpressure intensity
    • Define bp = min( 1 , max( 0 , a * ( q_len / cap ) + b * ( W_q / W_q_target ) ) ), with a,b ∈ [0,1].
    • Watermarks: wm_low < wm_high. When q_len/cap >= wm_high, trigger rate-limit or drop; relax when below wm_low.
  2. Control actions
    • Ingress: shaping(rps), increase batch_size, priority demotion.
    • Egress: decrease prefetch, increase consumer K_thr, scale out workers.
  3. Feedback cadence
    Update period T_bp should satisfy T_bp << W_q to avoid under/overshoot.

VI. Overflow and Drop Policies

  1. Policy families and applicability
    • tail_drop: drop newly arrived messages; typical for ordered channels.
    • head_drop: drop oldest messages; favors timeliness (minimizes stale backlog).
    • random_drop: RED-like smoothing of congestion.
    • shed_by_key(id): rate-limit or drop by idemp_key to suppress noisy sources.
  2. Selection guidelines
    • Optimize P99(latency): prefer head_drop or random_drop.
    • Optimize accuracy: prefer tail_drop or blocking (evaluate upstream rho).

VII. Batching and ACK Semantics


VIII. Delivery Semantics and Deduplication

  1. Semantics
    • at_most_once: no retry, p_drop can be non-zero; lowest latency.
    • at_least_once: duplicates allowed; use idemp_key for deduplication.
    • exactly_once*: approximate via idemp_key + idempotent storage.
  2. Dedup window
    Maintain dedup_table over (idemp_key, ts_last); rule: if tau_mono - ts_last <= Delta_t_dedup then drop duplicate.

IX. End-to-End Timing and Age Control

  1. Age and expiry
    Message age: age(msg,t) = t - ts; expiry when age(msg,t) > ttl.
  2. Delay budget decomposition
    budget_total = W_q_in + w(proc) + W_q_out; target P99(budget_total) <= SLO.
  3. Arrival-time reference
    If using propagation arrival time T_arr to calibrate cross-domain timing, adopt both forms:
    • T_arr = ( 1 / c_ref ) * ( ∫ n_eff d ell )
    • T_arr = ( ∫ ( n_eff / c_ref ) d ell )
    • Report the discrepancy delta_form.

X. Rate-Limit Coordination and Stability Conditions


XI. Capacity Planning and Baselines


XII. Interface Bindings and Invariants (Aligned with I70-3)

  1. API sketch
    • chan_open(name:str, cap:int, mode:str="mpmc") -> ChanRef (validate cap>0).
    • chan_put(ch, msg|batch, key?, timeout?) -> bool (timeouts increment TS.timeout.count).
    • chan_get(ch, max_batch:int=1, timeout?) -> list (empty-timeout increments TS.timeout.count).
    • set_backpressure(ch, strategy:dict) -> None (strategy includes wm_low, wm_high, actions[]).
  2. Invariants
    q_len <= cap; bp ∈ [0,1]; ACK is serialized or idempotent; trace_link(span,eid) is complete.

XIII. Observability and SLIs

  1. TS. mappings*
    • TS.chan.cap, TS.chan.q_len, TS.backpressure.level, TS.drop.count, TS.retry.count, TS.timeout.count.
    • Latency: TS.sli.queue_time_ms, TS.sli.latency_ms, TS.sli.p99_ms; throughput: TS.sli.qps; errors: TS.sli.err_rate.
  2. Dimensional compliance
    Verify check_dim( L - lambda * W ) = 0; window is SLA_window.

XIV. Contracts and Test Matrix

  1. Must-pass cases
    • Steady state with rho < 1; watermark wm_high triggers rate limit; head_drop/tail_drop/random_drop correctness.
    • Effective dedup under at_least_once; ack_timeout retries preserve ordering constraints; Delta_t_dedup takes effect.
    • Aging and expiry: ttl expiry drops are audited.
  2. Assertion structure (example)
    assert_thread_contract(G, tests=[ {"type":"queue_stability","chan":"ingress","rho_lt":1.0}, {"type":"slo","p99_ms_le":SLO}, {"type":"drop_policy","mode":"head_drop"} ]).

XV. Operating Flow Mx-2 (Closed-Loop Backpressure)


XVI. Exit Criteria and Deliverables


Copyright & License (CC BY 4.0)

Copyright: Unless otherwise noted, the copyright of “Energy Filament Theory” (text, charts, illustrations, symbols, and formulas) belongs to the author “Guanglin Tu”.
License: This work is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0). You may copy, redistribute, excerpt, adapt, and share for commercial or non‑commercial purposes with proper attribution.
Suggested attribution: Author: “Guanglin Tu”; Work: “Energy Filament Theory”; Source: energyfilament.org; License: CC BY 4.0.

First published: 2025-11-11|Current version:v5.1
License link:https://creativecommons.org/licenses/by/4.0/