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

Appendix B — Strategy Templates and Configuration


I. Scope and Conventions

  1. Applicable domains
    Concurrency control, scheduling, backpressure, rate limiting, timeouts and retries, idempotency and deduplication, resource quotas and isolation, arrival-time calibration, observability and SLOs.
  2. 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.
  3. 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)

  1. Objectives
    Minimize T_make(G), protect the critical path crit(G); maximize throughput subject to K_thr and quotas.
  2. 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".
  3. 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

  1. 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 ).
  2. 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 ).
  3. 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)

  1. 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.
  2. Leaky bucket
    rate_limit.mode = "leaky_bucket"; rate_limit.drain_rps; rate_limit.queue_cap.
  3. 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)

  1. Lower bound
    timeout_floor = T_arr + J + P99(service); enforce timeout >= timeout_floor.
  2. 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".
  3. Upper bound
    W_retry <= timeout * ( retries + 1 ) + J_total.
  4. Error mapping
    E_TIMEOUT|E_RATE_LIMIT|E_BACKPRESSURE are retryable; E_CONTRACT|E_DEDUP are not.
  5. Budgeted retry
    With a deadline, ensure sum(planned_delays) + E[service_left] <= deadline - now().

VI. Idempotency and Deduplication Strategy Templates

  1. Key and window
    • idempotency.key = "idemp_key"; idempotency.window_s = Delta_t_dedup.
    • Contract: f(x; idemp_key) = f(x; idemp_key).
  2. Storage
    idempotency.store ∈ {"inmem","redis","db"}; idempotency.ttl_s >= window_s.
  3. Merge policy
    merge ∈ {"first_wins","last_wins","combine"}; combine_fn must be explicitly registered.

VII. Resource Quota and Isolation Strategy Templates

  1. Scope
    scope ∈ {"batch","online","stream","control"}
  2. Quota fields
    • quota.cpu, quota.mem, quota.io, quota.net, quota.gpu.
    • isolation.cgroup=true; affinity=[cpu_ids]; numa.policy ∈ {"local","interleave"}.
  3. 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


IX. Arrival-Time Binding and Calibration Templates


X. Policy Composition and Precedence

  1. Decision order
    backpressure → rate_limit → timeout → retry → idempotency → quota.
  2. 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)


XII. Contractual Validation Pack (Assertion Templates)


XIII. Scenario Presets (Batch / Online / Streaming)


XIV. Versioning and Change Policy


XV. Quick Reference (Key Formulae and Thresholds)


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/