Commit Graph

8 Commits

Author SHA1 Message Date
f1fa182a4b AotPrep collections_hot matmul tuning and bench tweaks 2025-11-14 13:36:20 +09:00
376857a81f fix(perf): stabilize MIR emit for ny-llvmc/EXE benchmarks
Problem:
- Stage-B JSON extraction used fragile `awk '/^{/,/^}$/'`
- stdout noise caused empty JSON and bench failures
- arraymap/matmul/maplin --exe mode failed with "failed to emit MIR JSON"

Solution:
- Python3-based robust JSON extraction
  - Search for "kind":"Program" marker
  - Balance braces with quote/escape awareness
  - Resilient to stdout noise
- FORCE jsonfrag mode priority (HAKO_MIR_BUILDER_LOOP_FORCE_JSONFRAG=1)
  - Bypasses Stage-B entirely when set
  - Generates minimal while-form MIR with PHI nodes
- Multi-level fallback strategy
  - L1: Stage-B + selfhost/provider builder
  - L2: --emit-mir-json CLI direct path
  - L3: Minimal jsonfrag MIR generation
- cd $ROOT for Stage-B (fixes using resolution context)

Results:
-  arraymap --exe: ratio=200.00% (was failing)
-  matmul --exe: ratio=200.00% (was failing)
-  maplin --exe: ratio=100.00% (was failing)
-  Existing canaries: aot_prep_e2e_normalize_canary_vm.sh PASS
-  New canary: emit_mir_canary.sh PASS

Known Issues (workarounds applied):
- Stage-B compiler broken (using resolution: StringHelpers.skip_ws/2)
- --emit-mir-json CLI broken (undefined variable: local)
- Current jsonfrag mode bypasses both issues

Documentation:
- benchmarks/README.md: Added MIR emit stabilization notes
- ENV_VARS.md: Already documents HAKO_SELFHOST_BUILDER_FIRST, etc.

Next: Fix Stage-B using resolution to re-enable full optimization path

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 17:23:48 +09:00
dda65b94b7 Phase 21.7 normalization: optimization pre-work + bench harness expansion
- Add opt-in optimizations (defaults OFF)
  - Ret purity verifier: NYASH_VERIFY_RET_PURITY=1
  - strlen FAST enhancement for const handles
  - FAST_INT gate for same-BB SSA optimization
  - length cache for string literals in llvmlite
- Expand bench harness (tools/perf/microbench.sh)
  - Add branch/call/stringchain/arraymap/chip8/kilo cases
  - Auto-calculate ratio vs C reference
  - Document in benchmarks/README.md
- Compiler health improvements
  - Unify PHI insertion to insert_phi_at_head()
  - Add NYASH_LLVM_SKIP_BUILD=1 for build reuse
- Runtime & safety enhancements
  - Clarify Rust/Hako ownership boundaries
  - Strengthen receiver localization (LocalSSA/pin/after-PHIs)
  - Stop excessive PluginInvoke→BoxCall rewrites
- Update CURRENT_TASK.md, docs, and canaries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 16:40:58 +09:00
6055d53eff feat(phase21.5/22.1): MirBuilder JsonFrag refactor + FileBox ring-1 + registry tests
Phase 21.5 (AOT/LLVM Optimization Prep)
- FileBox ring-1 (core-ro) provider: priority=-100, always available, no panic path
  - src/runner/modes/common_util/provider_registry.rs: CoreRoFileProviderFactory
  - Auto-registers at startup, eliminates fallback panic structurally
- StringBox fast path prototypes (length/size optimization)
- Performance benchmarks (C/Python/Hako comparison baseline)

Phase 22.1 (JsonFrag Unification)
- JsonFrag.last_index_of_from() for backward search (VM fallback)
- Replace hand-written lastIndexOf in lower_loop_sum_bc_box.hako
- SentinelExtractorBox for Break/Continue pattern extraction

MirBuilder Refactor (Box → JsonFrag Migration)
- 20+ lower_*_box.hako: Box-heavy → JsonFrag text assembly
- MirBuilderMinBox: lightweight using set for dev env
- Registry-only fast path with [registry:*] tag observation
- pattern_util_box.hako: enhanced pattern matching

Dev Environment & Testing
- Dev toggles: SMOKES_DEV_PREINCLUDE=1 (point-enable), HAKO_MIR_BUILDER_SKIP_LOOPS=1
- phase2160: registry opt-in tests (array/map get/set/push/len) - content verification
- phase2034: rc-dependent → token grep (grep -F based validation)
- run_quick.sh: fast smoke testing harness
- ENV documentation: docs/ENV_VARS.md

Test Results
 quick phase2034: ALL GREEN (MirBuilder internal patterns)
 registry phase2160: ALL GREEN (array/map get/set/push/len)
 rc-dependent tests → content token verification complete
 PREINCLUDE policy: default OFF, point-enable only where needed

Technical Notes
- No INCLUDE by default (maintain minimalism)
- FAIL_FAST=0 in Bring-up contexts only (explicit dev toggles)
- Tag-based route observation ([mirbuilder/min:*], [registry:*])
- MIR structure validation (not just rc parity)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 19:42:42 +09:00
77d4fd72b3 phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0 2025-11-06 15:41:52 +09:00
d62114c705 Core-13 pure: add CI workflows, VM e2e tests, LLVM parity bridge (minimal); do not touch private docs 2025-09-07 07:28:53 +09:00
7d88c04c0e wip(phase15): AOT修正作業中 - Nyプラグインと標準ライブラリ実装
Phase 15のAOT/ネイティブビルド修正作業を継続中。
ChatGPTによるstd実装とプラグインシステムの改修を含む。

主な変更点:
- apps/std/: string.nyashとarray.nyashの標準ライブラリ追加
- apps/smokes/: stdライブラリのスモークテスト追加
- プラグインローダーv2の実装改修
- BoxCallのハンドル管理改善
- JIT hostcall registryの更新
- ビルドスクリプト(build_aot.sh, build_llvm.sh)の調整

まだ修正作業中のため、一部の機能は不完全な状態。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 06:24:08 +09:00
8ec80a35c3 feat(benchmark): add comprehensive performance benchmarking system
🚀 Phase 8.2 PoC2 Achievement: 280x WASM performance boost proven\!

## New Features:
- Complete benchmark framework (src/benchmarks.rs)
- CLI integration: --benchmark --iterations options
- 3-backend comparison: Interpreter/VM/WASM
- Automated performance measurement & reporting

## Benchmark Results (100 iterations average):
- WASM: 0.17ms (280x faster than Interpreter\!)
- VM: 16.97ms (2.9x faster than Interpreter)
- Interpreter: 48.59ms (baseline)

## Added Files:
- benchmarks/bench_{light,medium,heavy}.nyash - Test cases
- benchmark_summary_20250814.md - Clean results
- wasm_demo/ - Browser execution environment

## Documentation Updates:
- docs/execution-backends.md - Added benchmark usage
- docs/CURRENT_TASK.md - Phase 8.3 Copilot coordination
- CLAUDE.md - Quick benchmark access

## Copilot Integration Ready:
- Phase 8.3 merge conflict avoidance strategy documented
- Benchmark framework ready for Box operation performance validation
- CLI integration preserved for future enhancements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 07:19:23 +09:00