Skip to content
PT

Static copy

Copied from docs/en/decisions/adp-011.md in https://github.com/poppy-team/aipo-lang (MIT). Pinned to revision ce47c4e070404fc41722ccd8e2b7b808b99062a8, blob e45817a8b8dac53005297387e5b68f659d594c7e. The source repository remains canonical; this copy is refreshed through a sync pull request, not live.

ADP-011 — Structural Performance & Ergonomics Roadmap ​

  • Status: Approved
  • Date: 2026-09-26
  • Deciders: Poppy Team
  • Phase: Post-v0.1.0 Planning / Architectural Evolution

Context & Diagnosis ​

During phase P04 and early P05, seven local micro-optimization experiments failed to produce reproducible speedups and were accordingly rolled back.

An architectural audit proved that the Aipo bytecode interpreter operates with a structural floor of ~100ns per opcode (~300 CPU cycles). Local micro-optimizations cannot penetrate this floor. Comparative measurements against Wren 0.4.0 and Luau 0.739 revealed systemic gaps in arithmetic loops and dynamic method dispatch overhead.


Architectural Performance Decisions ​

  1. Value Compaction to 16/24 Bytes:

    • Reduce the size of Value from 48 bytes down to 16-24 bytes, slashing memory bandwidth pressure by up to 66% and quadrupling value density per L1 cache line.
  2. Method Invocation Fusion (InvokeMethod):

    • Compile direct calls expr.method(args...) into the fused opcode InvokeMethod (rather than separate GetField + Call), eliminating ~200,000 ephemeral BoundMethod allocations in iterative workloads.
  3. Dispatch Loop with Hoisted Variables:

    • Refactor the VM inner loop with critical execution state pinned in local CPU registers (ip, stack_base, code).
  4. Superinstructions & Specialization:

    • Specialized opcode variants such as Call0..Call4 and GetLocal0..GetLocal3 eliminating extra immediate decoding overhead.

Language Ergonomics Decisions ​

  1. Structured Faults (Model B+): Allow fail to accept any value or struct instance as its fault payload with strongly-typed inspection in recover.
  2. Pattern Matching & Destructuring: Introduce match expr with structural and collection destructuring.
  3. Static Type Narrowing: Flow-sensitive type inference in aipo-sema to elide redundant dynamic runtime type checks.