ReviewOS

zig-utils/zig-js

JIT: optimize tiering policy, warmup, and compilation cost

#481
Open chris opened this 8 days ago ·
8 days ago

Parent: #459 Depends on: #461, #466, #467, #471, #480

Goal

Build a general tiering policy that minimizes time-to-performance, compile CPU, code size, invalidation churn, and warmup latency across short- and long-lived workloads.

Current boundary

The comparison harness deliberately performs ten warm calls to cross the current eight-entry optimizer threshold. That validates warmed performance but does not prove the threshold/policy is right for applications, cold work, polymorphism, shared realms, or large code.

Scope

  • Profile entry/backedge heat, loop trip count, dispatch cost, runtime-operation mix, polymorphism, allocation, deopt/invalidation history, compile cost, and expected remaining lifetime.
  • Select interpreter/VM/baseline/optimizer/OSR transitions with a bounded cost-benefit model rather than one global count.
  • Add compile queue/background compilation only if artifact claims, Context teardown, no-GIL readers, W^X, memory pressure, and deterministic tests remain exact.
  • Apply exponential backoff/cooldown to repeated rejection/deopt/invalidation based on reason, while allowing changed evidence to retry.
  • Bound compiled bytes and prioritize/evict by measured value under #480.

No-workaround rules

  • No benchmark/function/source recognition, magic threshold tuned only to #44, permanent JIT disable after one ordinary miss, hidden warmup, or compile work moved outside a declared cold timer.

Acceptance

  • #460 reports time-to-tier, compile latency/CPU, code bytes, publications, rejects, deopts, invalidations, and steady attribution per workload.
  • Policy improves a predeclared blend of cold, warm, short, long, monomorphic, polymorphic, and no-GIL work without row-level regression.
  • Deterministic policy tests and forced-tier semantic differentials cover every transition and backoff state.
  • Compilation/publication/invalidation/teardown races pass TSan and artifact lifetime gates.
  • Full reference-host evidence includes both wall time and compile/code-memory cost.

Foundation

Tier records from #52/#431 and managed-baseline preference at df86d687.

8 days ago

#555 is complete and improves tier eligibility without weakening semantics. 00a401d7 derives uses_arguments from parse-time IdentifierReferences, so comments, strings, property names, identifier substrings, and nested ordinary scopes no longer unnecessarily disqualify an owning function from bytecode/JIT policy. The forced-tier witness and 2,470 affected test262 cases pass; exact-parent evidence is in 59638193.

Sign in to comment on this issue.