Home / Docs-Technical WhitePaper / 07-EFT.WP.Core.Threads v1.0
Appendix B — Strategy Templates and Configuration
I. Scope and Conventions
- Applicable domains
Concurrency control, scheduling, backpressure, rate limiting, timeouts and retries, idempotency and deduplication, resource quotas and isolation, arrival-time calibration, observability and SLOs. - Unified syntax
- Config is key–value with hierarchical merge; durations are in seconds unless a field name ends with _ms (milliseconds).
- Strategy objects are named policy and compose additively:
policy = rate_limit ⊕ backpressure ⊕ retry ⊕ timeout ⊕ idempotency ⊕ quota.
- Key symbols
- Rates and utilization: lambda, mu, rho = lambda / mu.
- Queues and delays: L, L_q, W, W_q, with L = lambda * W.
- Arrival-time dual forms: T_arr = ( 1 / c_ref ) * ( ∫ n_eff d ell ); T_arr = ( ∫ ( n_eff / c_ref ) d ell ).
- Dual-form gap: delta_form = | ( 1 / c_ref ) * ( ∫ n_eff d ell ) - ( ∫ ( n_eff / c_ref ) d ell ) |.
II. Scheduling Strategy Templates (DAG and Thread Pools)
- Objectives
Minimize T_make(G), protect the critical path crit(G); maximize throughput subject to K_thr and quotas. - Template fields
- scheduler.type ∈ {"work_steal","fair","priority"}
- scheduler.max_parallel = K_thr; scheduler.affinity = [cpu_id...]; scheduler.prio_bias ∈ [-1,1].
- scheduler.preemption.quantum_ms ∈ [1,50]; scheduler.queue = "mpmc".
- Constraints
- T_make(G) approx sum(w on crit(G)) + sum(c on crit(G)).
- If rho >= 1, reduce readiness or apply rate limiting to avoid drifting into instability.
III. Channel and Backpressure Strategy Library
- Signal definition
- bp = f(q_len, cap, W_q), with bp ∈ [0,1].
- Reference function:
bp = clamp( alpha*(q_len/cap) + beta*(W_q/W_q_target) + gamma*max(0, rho-1), 0, 1 ).
- Strategy family
- type="block": producers block when bp >= th_block.
- type="drop": when bp >= th_drop drop newest or oldest (drop_policy ∈ {"newest","oldest"}).
- type="shed": return E_BACKPRESSURE upstream to negotiate limiting.
- type="resize": cap' = clamp( cap * (1 + k*(bp - bp_target)), cap_min, cap_max ).
- Suggested thresholds
- th_block = 0.6, th_drop = 0.8, bp_target = 0.5, alpha=0.7, beta=0.2, gamma=0.1.
- Maintain rho < 1 for approximate stability; document the estimation sources for lambda, mu.
IV. Rate Limiting Strategy Templates (Token/Leaky Bucket)
- Token bucket
- rate_limit.mode = "token_bucket"; rate_limit.rps; rate_limit.burst; rate_limit.warmup_s.
- Dynamic coupling: rps' = rps * ( 1 - bp )—slow down as bp rises.
- Leaky bucket
rate_limit.mode = "leaky_bucket"; rate_limit.drain_rps; rate_limit.queue_cap. - Failure semantics
Exceeding the envelope returns E_RATE_LIMIT or waits until timeout; when combined with retry, budget the total (see §V).
V. Timeout and Retry Strategy Templates (with Jitter)
- Lower bound
timeout_floor = T_arr + J + P99(service); enforce timeout >= timeout_floor. - Retry parameters
- retry.max; retry.backoff ∈ {"const","lin","exp"}; retry.base_s; retry.jitter ∈ {"none","full"}.
- Jitter recommendation: delay' = U(0, delay) for jitter="full".
- Upper bound
W_retry <= timeout * ( retries + 1 ) + J_total. - Error mapping
E_TIMEOUT|E_RATE_LIMIT|E_BACKPRESSURE are retryable; E_CONTRACT|E_DEDUP are not. - Budgeted retry
With a deadline, ensure sum(planned_delays) + E[service_left] <= deadline - now().
VI. Idempotency and Deduplication Strategy Templates
- Key and window
- idempotency.key = "idemp_key"; idempotency.window_s = Delta_t_dedup.
- Contract: f(x; idemp_key) = f(x; idemp_key).
- Storage
idempotency.store ∈ {"inmem","redis","db"}; idempotency.ttl_s >= window_s. - Merge policy
merge ∈ {"first_wins","last_wins","combine"}; combine_fn must be explicitly registered.
VII. Resource Quota and Isolation Strategy Templates
- Scope
scope ∈ {"batch","online","stream","control"} - Quota fields
- quota.cpu, quota.mem, quota.io, quota.net, quota.gpu.
- isolation.cgroup=true; affinity=[cpu_ids]; numa.policy ∈ {"local","interleave"}.
- Suggested baselines
- online: quota.cpu=1–2, quota.mem="512Mi–1Gi", burst=10%.
- stream: quota.cpu=2–4, quota.mem="2Gi", cap >= 10 * rps_target * W_q_target.
- batch: quota.cpu>4, lowered priority prio=-1.
VIII. Observability, Alerting, and Budget Templates
- SLI set
Latency: svc.latency_ms{quantile}; Availability: 1 - ErrRate; Queue: chan.q_len; Backpressure: bp. - SLO
SLO.latency.P99 <= target_ms; SLO.err_budget = 1 - SLO.availability. - Burn alerts
Window SLA_window; dual thresholds with burn_rate ∈ {2h, 1h} bands; crossing triggers degradation or limiting. - Tracing
Create trace_span at critical nodes; associate eid, pid_thr via trace_link to preserve hb.
IX. Arrival-Time Binding and Calibration Templates
- Data fields
gamma(ell), d ell, L_gamma = ( ∫ 1 d ell ), n_eff(x,t), c_ref. - Calibration flow
Compute both forms of T_arr, obtain delta_form; only pass if delta_form <= tol_form_ms. - Suggested
tol_form_ms = 1 (tune per scenario); report externally with ts, evaluate internally with tau_mono.
X. Policy Composition and Precedence
- Decision order
backpressure → rate_limit → timeout → retry → idempotency → quota. - Conflict handling
- If rate_limit and backpressure trigger together, first reduce rps'; if bp remains high, switch type="shed".
- If deadline conflicts with retry, satisfy deadline first and stop retries early.
XI. Strategy Snippets (Drop-In Examples)
- Execution graph & scheduling
scheduler: { type: "work_steal", max_parallel: 8, prio_bias: 0.2, preemption: { quantum_ms: 5 } } - Channel & backpressure
chan: { name: "ingress", cap: 10000, bp: { type: "resize", alpha: 0.7, beta: 0.2, gamma: 0.1, bp_target: 0.5, cap_min: 2000, cap_max: 20000 } } - Rate limiting
rate_limit: { mode: "token_bucket", rps: 1500, burst: 300, warmup_s: 10, dynamic: "rps' = rps * (1 - bp)" } - Timeout & retry
timeout: { seconds: 0.8, floor_expr: "T_arr + J + P99(service)" }
retry: { max: 3, backoff: "exp", base_s: 0.05, jitter: "full" } - Idempotency & dedup
idempotency: { key: "idemp_key", window_s: 120, store: "redis", merge: "first_wins" } - Resources & isolation
quota: { cpu: 2, mem: "1Gi", io: "100MBps" }
isolation: { cgroup: true, affinity: [0,1], numa: { policy: "local" } } - Observability & SLO
sli: { latency_ms: [50,90,99], error_rate: true, q_len: true, bp: true }
slo: { p99_ms: 200, availability: 0.999, window: "28d", err_budget_burn: { fast: "1h", slow: "24h" } } - Arrival-time calibration
arrival: { tol_form_ms: 1.0, equations: ["T_arr"], enforce: true }
XII. Contractual Validation Pack (Assertion Templates)
- {"type":"rho_lt_1","chan":"ingress","lambda":"obs","mu":"obs"}
- {"type":"deadline","expr":"T_make <= 180000 ms"}
- {"type":"arrival_form_consistency","tol_form_ms":1.0}
- {"type":"timeout_floor","expr":"timeout >= T_arr + J + P99_service"}
- {"type":"ell_monotonic","field":"ell_seq","strict":true}
XIII. Scenario Presets (Batch / Online / Streaming)
- Batch
scheduler.type="work_steal"; retry.max=0–1; rate limiting off; quota.cpu>4; bp.type="block". - Online service
rate_limit.rps = QPS_target * 1.1; burst = QPS_target * 0.2; retry.backoff="exp"; timeout = P99(service)+margin; bp.type="shed". - Streaming
chan.cap >= 10 * rps_target * W_q_target; bp.type="resize"; retry.max<=2; idempotency.window_s >= watermark_s.
XIV. Versioning and Change Policy
- Use semantic schema_version; breaking changes require major+1 plus a compatibility layer.
- Any policy change must emit diff, Trace=[source -> method -> artifact], and signature.
- Roll out within an SLA_window with canary and rollback plan.
XV. Quick Reference (Key Formulae and Thresholds)
- Stability: rho = lambda / mu < 1.
- Backpressure: bp = clamp( alpha*(q_len/cap) + beta*(W_q/W_q_target) + gamma*max(0, rho-1), 0, 1 ).
- Rate reduction: rps' = rps * ( 1 - bp ).
- Timeout floor: timeout >= T_arr + J + P99(service).
- Retry upper bound: W_retry <= timeout * ( retries + 1 ) + J_total.
- Arrival-time consistency: delta_form <= tol_form_ms.
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/