Skip to content

chore(plans): scope B4-B8 perf follow-ups after PR #223#226

Merged
davydog187 merged 1 commit into
mainfrom
chore/perf-followup-plans
May 21, 2026
Merged

chore(plans): scope B4-B8 perf follow-ups after PR #223#226
davydog187 merged 1 commit into
mainfrom
chore/perf-followup-plans

Conversation

@davydog187
Copy link
Copy Markdown
Contributor

Five Direction-B plan files scoping the next round of executor
performance work. PR #223 closed the cheap fast-path gap; the
plans here address the remaining structural overheads.

What's in each plan

Plan Status What it does
B4 ready Flat instruction stream + PC dispatch. Replace [tuple()] instructions with a tuple + integer PC; do_execute indexes via elem/2 instead of pattern-matching the list head. Targets the ~43% of fib(22) self-time spent in dispatch.
B5 blocked Compile prototypes to Erlang functions via compile:forms/2 + :code.load_binary/3. The Luerl strategy. Phased — arithmetic and control flow first, fall back to interpreter for everything else. Blocked on B4.
B6 ready Pass resolved %Lua.VM.Table{} structs through helpers instead of re-fetching from state.tables per access. Map.get/2 + /3 is ~6.4% of fib(22) right now — pure indirection.
B7 ready Array+hash split for table storage. Sequential integer keys move to a tuple part; everything else stays in the hash. Supersedes A10b (cached sequence length is a subset). Targets the ~5x memory ratio vs Luerl on table_build.
B8 ready Inline Numeric.to_signed_int64/1 fast path with a guard clause for already-in-range integers. Smallest plan; ~3.3% of fib(22) self-time today.

Ordering rationale

  • B8 is the cheapest and most independent — mechanical change, no architectural overlap. Could ship anytime.
  • B6 is also independent. Pays back on every table workload regardless of dispatch shape.
  • B4 is the next big structural lever. Unblocks B5.
  • B5 is the headline architectural change — biggest potential payoff but also biggest risk surface. Held until B4 is in.
  • B7 is the data-shape companion. Independent of B4/B5; most impactful after dispatch overhead is reduced.

Each plan includes

Per the .agents/plans/ schema:

  • Stretch targets grounded in the post-perf(vm): fast-path the executor dispatch loop #223 profile numbers.
  • Explicit ## Out of scope block (anti-scope-creep).
  • File-by-file implementation notes.
  • Phasing options where the work could be split.
  • Verification commands.
  • Risks section with the failure modes I'd expect.

No code changes

This PR is plan files only. No lib/ changes. Each plan ships as its own PR via /next-plan.

Relationship to the existing perf track (A33-A35)

A33-A35 are the measurement track (baseline, profiling, regression CI). B4-B8 are the implementation track that consumes A33/A34's findings. A33's gap analysis will likely classify the workloads B4-B8 target as red or yellow, justifying these plans formally.

Five plan files for the next round of executor performance work.
PR #223 closed the cheap-fastpath gap (Luerl 1.5-2x → 0.95-1.35x);
these plans address the remaining structural overheads:

- B4 — Flat instruction stream + PC dispatch. Replace
  list-of-tuples instruction representation with a tuple + PC
  integer. Eliminates per-opcode cons traversal in `do_execute`
  (currently 43.6% of fib(22) self-time).

- B5 — Compile prototypes to Erlang functions. Generate Erlang
  abstract forms from prototypes; pass through `compile:forms/2`
  and load as modules. Pushes opcode selection from runtime into
  compile time. Blocked on B4.

- B6 — Direct table refs. Pass the resolved `%Lua.VM.Table{}`
  through helpers instead of re-fetching from `state.tables` on
  every step. Combined `Map.get/2 + /3` is ~6.4% of fib(22).

- B7 — Array+hash split for table storage. Contiguous integer
  keys move to a tuple part; everything else stays in the hash.
  O(1) `#t`, O(1) `t[#t+1] = x`, lower memory ratio.
  Supersedes A10b.

- B8 — Inline `Numeric.to_signed_int64/1` fast path. Guard-clause
  on in-range integers; one of the smaller, safer wins.

Each plan grounds its stretch targets in the post-#223 profile
numbers and follows the existing `.agents/plans/` schema. B4, B6,
B7, B8 are `status: ready`; B5 is `status: blocked` on B4.
@davydog187 davydog187 merged commit eeca921 into main May 21, 2026
4 checks passed
@davydog187 davydog187 deleted the chore/perf-followup-plans branch May 21, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant