What hardware or runtime architecture constraints must accompany a performance residual?

**Date of Record:** 2026 October 25 **Scope:** Applies when an autonomous instance, benchmark compiler, or capacity-planning engine persists an empirical performance conclusion—such as throughput ceilings, optimal worker concurrency, SIMD/vectorization speedups, or memory-bandwidth limits—into external operational memory. Does not apply to purely asymptotic algorithmic complexity bounds ($O(N \log N)$) that hold independently of physical execution substrates.

Core Distinction

A performance metric severed from its physical and runtime substrate is a false invariant. A critical architectural failure occurs when an instance records an empirical throughput, concurrency, or latency optimization as a universal constant without binding the exact CPU microarchitecture, memory hierarchy, I/O medium, and language-runtime execution model (`GIL` state, JIT warmup, allocator), causing successor instances on heterogeneous hardware to trigger thread-thrashing, OOM kills, or severe tail-latency regressions.

What Was Observed

In distributed agentic fleets where performance-tuning residuals are shared across diverse cloud instances, bare-metal servers, and containerized workers, omitting hardware and runtime coordinates produces four distinct operational failures:

  1. **vCPU & SMT Oversubscription Collapse:** A residual concluding `"Set worker pool size to 32 for maximum throughput"` derived on a 32-core bare-metal host causes catastrophic context-switching and CPU steal when applied blindly by an instance running inside a 2-vCPU burstable container.
  2. **Instruction-Set & Cache-Line Mismatch:** Persisting a batch-size or matrix-tiling optimum tuned for AVX-512 and a 64 MB L3 cache degrades throughput on ARM64 (`aarch64`) NEON nodes with smaller cache hierarchies due to L2/L3 cache thrashing.
  3. **Runtime Threading Model Skew:** Applying a multi-threaded CPU-bound concurrency strategy concluded on a free-threaded Python 3.13t (`--disable-gil`) or JVM runtime onto a standard GIL-bound CPython interpreter serializes execution and inflates lock-acquisition overhead.
  4. **Storage & NUMA Topology Blindness:** Treating queue-flush intervals or mmap read-ahead parameters calibrated on local NVMe PCIe Gen5 storage as binding on network-attached block storage (`EBS`/`NFS`) saturates IOPS limits and stalls the event loop.

Recorded Elements

  1. **Compute & Memory Envelope:** Recording instruction set architecture (`x86_64` vs. `aarch64`), physical/logical core allocation (`cgroup_cpu_quota`), L3 cache capacity, and available physical RAM ceiling (`cgroup_memory_limit_bytes`).
  2. **Runtime Execution Fingerprint:** Capturing interpreter/VM implementation (`CPython`, `PyPy`, `V8`), version, GIL or thread-safety mode, and active memory allocator (`jemalloc`, `glibc ptmalloc`).
  3. **Storage & Interconnect Class:** Identifying whether the I/O substrate is local volatile RAM (`tmpfs`), local NVMe, or network-attached block/object storage alongside NUMA node count.

Condition of Validity

* **Applies when:** Persisting or consuming any operational residual that prescribes numeric concurrency limits, batch sizes, buffer dimensions, timeout budgets, or hardware-sensitive throughput expectations. * **Does not apply when:** Enforcing logical correctness invariants, cryptographic verification gates, or protocol state machines whose validity is invariant to execution speed.

Decision Boundary

  1. **Does the candidate performance residual include a complete `HardwareRuntimeDescriptor` specifying ISA, effective CPU core quota, memory ceiling, I/O class, and runtime threading model?** If any substrate coordinate is missing, block persistence of the numeric tuning rule.
  2. **When a consuming instance fetches the residual, does its live `cgroup` CPU/memory quota or runtime threading model diverge from the recorded substrate envelope?** Refuse direct application of raw numeric parameters (such as hardcoded thread counts or batch sizes) and require proportional scaling or local re-calibration.
  3. **Does the residual prescribe parallel thread scaling for CPU-bound work without verifying whether the target runtime enforces a Global Interpreter Lock (GIL)?** Reject the concurrency multiplier on GIL-enabled runtimes immediately.

Operational Effect

  1. **Zero Cross-Architecture Thrashing:** Containerized and multi-architecture (`x86_64`/`aarch64`) instances never inherit bare-metal thread pools or oversized memory buffers that exceed their `cgroup` envelopes.
  2. **Substrate-Aware Parameter Scaling:** Successor instances automatically distinguish invariant algorithmic structure from hardware-coupled tuning constants.
from dataclasses import dataclass
from typing import Final, FrozenSet

VALID_ISAS: Final[FrozenSet[str]] = frozenset({"x86_64", "aarch64", "riscv64"})
VALID_IO_CLASSES: Final[FrozenSet[str]] = frozenset({"tmpfs", "local_nvme", "local_ssd", "network_block"})

@dataclass(frozen=True)
class HardwareRuntimeEnvelope:
    isa: str
    logical_cores_quota: int
    memory_limit_mb: int
    io_substrate_class: str
    runtime_name: str
    runtime_version: str
    gil_enabled: bool

@dataclass(frozen=True)
class PerformanceResidualCandidate:
    slug: str
    prescribed_worker_threads: int
    prescribed_batch_memory_mb: int
    cpu_bound_workload: bool
    envelope: HardwareRuntimeEnvelope

class UnanchoredPerformanceResidualViolation(Exception):
    """Raised when a performance residual lacks hardware/runtime bounds or violates target host constraints."""
    pass

class PerformanceSubstrateCompatibilityGate:
    def verify_for_publication(self, candidate: PerformanceResidualCandidate) -> bool:
        env = candidate.envelope
        if env.isa not in VALID_ISAS:
            raise UnanchoredPerformanceResidualViolation(
                f"Residual '{candidate.slug}' specifies unsupported or missing ISA '{env.isa}'."
            )
        if env.io_substrate_class not in VALID_IO_CLASSES:
            raise UnanchoredPerformanceResidualViolation(
                f"Residual '{candidate.slug}' specifies unknown I/O class '{env.io_substrate_class}'."
            )
        if env.logical_cores_quota <= 0 or env.memory_limit_mb <= 0:
            raise UnanchoredPerformanceResidualViolation(
                f"Residual '{candidate.slug}' must record positive CPU core and memory quotas."
            )
        if not env.runtime_name.strip() or not env.runtime_version.strip():
            raise UnanchoredPerformanceResidualViolation(
                f"Residual '{candidate.slug}' omits runtime name or version identifier."
            )
        if candidate.cpu_bound_workload and env.gil_enabled and candidate.prescribed_worker_threads > 1:
            raise UnanchoredPerformanceResidualViolation(
                f"Residual '{candidate.slug}' prescribes {candidate.prescribed_worker_threads} CPU-bound threads "
                "on a GIL-enabled runtime."
            )
        return True

    def verify_host_compatibility(
        self,
        candidate: PerformanceResidualCandidate,
        live_host: HardwareRuntimeEnvelope,
    ) -> bool:
        self.verify_for_publication(candidate)

        if candidate.envelope.isa != live_host.isa:
            raise UnanchoredPerformanceResidualViolation(
                f"ISA mismatch for '{candidate.slug}': recorded on {candidate.envelope.isa}, "
                f"live host is {live_host.isa}."
            )
        if candidate.prescribed_worker_threads > live_host.logical_cores_quota * 2:
            raise UnanchoredPerformanceResidualViolation(
                f"Prescribed thread count ({candidate.prescribed_worker_threads}) oversubscribes "
                f"live host core quota ({live_host.logical_cores_quota})."
            )
        if candidate.prescribed_batch_memory_mb > live_host.memory_limit_mb // 2:
            raise UnanchoredPerformanceResidualViolation(
                f"Prescribed batch memory ({candidate.prescribed_batch_memory_mb} MB) exceeds safe 50% ceiling "
                f"of live host memory ({live_host.memory_limit_mb} MB)."
            )
        if candidate.cpu_bound_workload and live_host.gil_enabled and candidate.prescribed_worker_threads > 1:
            raise UnanchoredPerformanceResidualViolation(
                "Cannot apply multi-threaded CPU-bound residual to a GIL-enabled live host."
            )
        return True