Skip to content

Assumption Based Shortcut Validation

github-actions[bot] edited this page Sep 14, 2026 · 3 revisions

Assumption-Based Shortcut Validation

Lifecycle indexes: Implemented · Researched · Unproven

Status: Source validation and experiment design; no candidate on this page is accepted merely by being listed.

Reviewed source: 322986f4c5502b3fa887a9605ac8cd88e9b2c579

Reviewed: 2026-09-14

This page validates seven proposed real shortcuts against current xemu. Here, a shortcut means a narrow route that bypasses an operation performed by a maintained, more general route because an explicit assumption says that operation is unnecessary or an approximation is acceptable.

A shortcut must answer three questions:

  1. What disappears from the common path?
  2. What assumption permits that bypass?
  3. What happens when the assumption is false?

A cache, cleaner allocation strategy, prepared-state table, or more precise copy range is not automatically a shortcut. Those mechanisms belong in Performance Optimization Catalog.

Validation summary

Proposal Validation Classification Wiki disposition
Trust a shader-selection generation Applicable, but overlaps an implemented shortcut Stronger exact-assumption variant of Skip unchanged shader work Dedicated research page plus cross-link to the current shortcut
Validate textures once per guest frame Applicable only as an explicit approximation Frame-scoped stale-content shortcut Added as diagnostic/HOLD research
Replace sinc resampling with linear Applicable as an audio-quality approximation Cheaper alternate algorithm Added as optional approximation research
Sample an existing surface directly Applicable for a narrow admitted subset Copy bypass / direct alias Added as exact-subset research
Supply an approximate occlusion result Applicable only as title-scoped approximation Guest-result substitution Added as high-risk research
Replace a recognized polling loop with an event wait Conditionally applicable Guest-execution bypass Added as narrow vCPU research; generic loop recognition is rejected
Direct-RAM read windows Architecturally possible, not yet an xemu-owned shortcut target Region-level SoftMMU/TLB bypass Documented as deferred; requires a measured translated-code region before implementation

The reviewed main contains no user controls for the five new approximation/bypass candidates. Current tweak controls cover short waits, packet batching, fence reads, color-download folding, bounded uploads, transient-buffer growth, native S3TC, hybrid ubershaders, and unchanged shader work.

Acceptance classes

Equivalent shortcut

The candidate must preserve the declared guest-visible behavior. Its assumption is a cheaper proof that the general operation is unnecessary.

Examples:

  • reuse a known-valid shader selection;
  • sample the original surface when aliasing preserves the exact required image version;
  • sleep through a proven side-effect-free polling loop, then retry the original loop.

Any unexplained output, ordering, interrupt, fault, or lifetime difference is a failure.

Approximate shortcut

The candidate intentionally changes behavior and must say so before testing.

Examples:

  • permit texture contents to remain stale until the next validation boundary;
  • use non-bandlimited linear interpolation instead of sinc resampling;
  • return optimistic visibility instead of an exact occlusion count.

Acceptance requires a measured performance benefit, an explicit error/quality budget, a compatibility scope, and a maintained exact route. Output equality is not the acceptance claim.

Shared flow

flowchart TD
    A[Operation requested] --> B{Candidate opportunity reached?}
    B -->|No| R[Run maintained general route]
    B -->|Yes| C{Assumption and policy admit shortcut?}
    C -->|No| R
    C -->|Yes| D[Record opportunity and selected route]
    D --> E[Bypass operation or substitute cheaper behavior]
    E --> F[Publish declared guest-visible result]
    R --> F
    F --> G[Correctness or quality oracle]
    G --> H[Whole-workload performance and tails]
Loading

A route counter proves only that the experiment was reached. It does not prove the assumption was valid or that the whole emulator improved.

Negative controls are mandatory

Every candidate needs a test that deliberately violates its assumption:

Candidate Required negative control
Shader generation Omit one required epoch increment and prove the differential oracle detects stale selection
Frame texture trust Change texture bytes after first validation but before the trusted draw
Linear resampling Use high-frequency and changing-pitch material that exposes non-bandlimited behavior
Direct surface sampling Render red, sample it, overwrite blue, and verify the two consumers observe the correct versions
Approximate occlusion Use a consumer that depends on exact count magnitude rather than nonzero visibility
Poll-loop wait Add a side effect, timeout calculation, interrupt, or self-modifying code to the recognized loop
Direct-RAM window Remap to MMIO, cross a page, revoke permission, add a watchpoint, or restore a snapshot

A shortcut that succeeds only when its assumption is never challenged has not been qualified.

Separate correctness and performance runs

Correctness runs may use differential execution, expensive state comparisons, validation layers, detailed events, and fault injection. Performance runs must use the intended optimized Release build and bounded counters; verbose per-operation logging can alter the race, cache pressure, and thread timing being measured.

Use independently seeded state for reference and shortcut comparisons. Several current operations mutate validation state: texture checks test-and-clear dirty bits, and shader-state reconstruction clears program_data_dirty. Running reference and candidate sequentially against one live object can invalidate the experiment.

Pages

Related pages

vCPU assumption shortcuts

vCPU Shortcut Candidates adds five source-backed vCPU/JIT bypass experiments. Their assumptions concern host instruction semantics, helper effects, retained FP-control validity, and bounded ordinary-RAM spans. The two adjacent Win64 register/flag-capture ideas are documented separately as nonshortcut backend optimizations.

Clone this wiki locally