feat(phase21.5): MirBuilder optimization prep + crate EXE infrastructure

Phase 21.5 optimization readiness - C-level performance target:
- MirBuilder: JsonFrag purify toggle (HAKO_MIR_BUILDER_JSONFRAG_PURIFY=1)
- Normalizer: extended f64 canonicalization + dedupe improvements
- loop_opts_adapter: JsonFrag path refinement for crate EXE compatibility

Infrastructure improvements:
- provider_registry: add diagnostics + ring-1 providers (array/console/map/path)
- mir_interpreter: add normalization/purify feature gates
- tools/selfhost_exe_stageb.sh: new end-to-end Stage-B→crate EXE pipeline
- tools/perf/microbench.sh: performance measurement tooling

Smoke tests (phase2100):
- Extend timeout 15s→120s for heavy crate EXE builds
- Add stageb_loop_jsonfrag_crate_exe_canary_vm.sh (target test)
- Add s3_backend_selector_crate_exe_vm_parity_return42_canary_vm.sh

Documentation:
- ENV_VARS.md: add Phase 21.5 optimization toggles
- README updates: clarify crate backend strategy
- phase215-optimization.md: new optimization roadmap

This commit sets the stage for Phase 21.5 critical optimization:
achieving C-level performance to decide hakorune's future viability.
This commit is contained in:
nyash-codex
2025-11-11 02:07:12 +09:00
parent ece91306b7
commit 07a254fc0d
49 changed files with 905 additions and 167 deletions

View File

@ -1,29 +1,24 @@
Smokes v2 — Quick vs Optional
Smokes v2 — Minimal Runner and Policy
Purpose
- Keep an alwayson, fast “quick” subset to sanitycheck core paths every time.
- Keep broader/experimental/hostdependent reps as optional, SKIPguarded.
Policy
- Use [SKIP:<reason>] prefix for environment/host dependent skips.
- Examples: [SKIP] hakorune not built, [SKIP:env] plugin path missing
- Keep reasons short and stable to allow grep-based canaries.
- Prefer JSON-only output in CI: set `NYASH_JSON_ONLY=1` to avoid noisy logs.
- Diagnostics lines like `[provider/select:*]` are filtered by default in `lib/test_runner.sh`.
Alwayson (quick)
- Runner: `tools/smokes/v2/run_quick.sh`
- Includes:
- Core crate/native reps (phase2100/run_all.sh) — SKIP when unavailable
- StageB Program(JSON) shape (phase2160: stageb_* canaries)
- loop_scan minimal canaries (!=' + else Break/Continue)
Helpers
- `tools/smokes/v2/lib/mir_canary.sh` provides:
- `extract_mir_from_output` — between [MIR_BEGIN]/[MIR_END]
- `assert_has_tokens`, `assert_skip_tag`, `assert_order`, `assert_token_count`
- `tools/lib/canary.sh` provides minimal, harness-agnostic aliases:
- `extract_mir_between_tags` — same as `extract_mir_from_output`
- `require_tokens token...` — fail if any token missing
Optional (perphase)
- Richer/experimental reps remain under `profiles/quick/core/phase*/run_all.sh` and individual canaries.
- Examples:
- registry_* tag observation canaries (structure only)
- program_to_mir_exe_* (host/tooling dependent, SKIPguarded)
Conventions
- 3state outcomes: PASS / SKIP / FAILFAIL should be rare and intentional
- SKIP guards are preferred over brittle environment assumptions.
- Add light canaries first; escalate to run_all only when stable and fast.
Usage
- Run quick set: `bash tools/smokes/v2/run_quick.sh`
- Run a phase: `bash tools/smokes/v2/profiles/quick/core/<phase>/run_all.sh`
- Run a single canary: `bash tools/smokes/v2/profiles/quick/core/<phase>/<name>_canary_vm.sh`
Notes
- Avoid running heavy integration smokes in CI by default. Use `--profile quick`.
- When a test depends on external tools (e.g., LLVM), prefer `[SKIP:<reason>]` over failure.
Quick tips
- EXE-heavy cases (e.g., `phase2100/*`) may take longer. When running quick with these tests, pass a larger timeout like `--timeout 120`.
- Smokes v2 auto-cleans temporary crate EXE objects created under `/tmp` (pattern: `ny_crate_backend_exe_*.o`) after the run.