Skip to content

Make array literal registry lazy on NaturalArray and expand PTAC native execution coverage#87

Merged
DanexCodr merged 6 commits into
mainfrom
copilot/optimize-naturalarray-o1
Apr 12, 2026
Merged

Make array literal registry lazy on NaturalArray and expand PTAC native execution coverage#87
DanexCodr merged 6 commits into
mainfrom
copilot/optimize-naturalarray-o1

Conversation

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

This PR addresses four gaps: array literal methods were eagerly materializing NaturalArray, PTAC still fell back frequently to the interpreter, code needed cleanup in touched paths, and an issue report artifact was requested.
The changes make NaturalArray method dispatch lazy/streamed where appropriate, broaden native PTAC opcode execution, and add a root-level issue report file summarizing findings and follow-ups.

  • Array literal registry: remove eager NaturalArray materialization

    • LiteralRegistry now treats NaturalArray separately from concrete List inputs.
    • map/filter on NaturalArray return lazy AbstractList views instead of forcing toList().
    • reduce on NaturalArray iterates by index (size() + get(i)) without pre-copying the full array.
    • Added clearer limit errors when operations exceed Integer.MAX_VALUE.
  • PTAC executor: reduce interpreter fallback surface

    • Added instruction-pointer execution with label indexing for branch flow.
    • Native support added for:
      • control flow: NOP, BRANCH, BRANCH_IF
      • lazy ops: LAZY_GET, LAZY_SET, LAZY_SIZE, LAZY_COMMIT
      • pattern ops: MAP, FILTER, REDUCE, FILTER_MAP
    • Kept recursive/closure-sensitive opcodes on fallback path where parity risk is higher.
  • Complexity validation runner (problem-specific)

    • Added ArrayLiteralRegistryComplexityRunner to compare eager-vs-lazy behavior across increasing sizes and verify size-independent setup characteristics for lazy map/filter.
  • Issue report submission artifact

    • Added root file ISSUE_REPORT_PTAC_NATURALARRAY.md with:
      • what changed,
      • remaining fallback areas,
      • follow-up issue recommendations.
// Before (NaturalArray path forced eager copy)
List<Object> source = arr.toList();

// After (NaturalArray map/filter path returns lazy view)
return new LazyNaturalArrayMapView(naturalArray, new NaturalArrayMapper() {
    @Override
    public Object map(long index, Object value) {
        return applyOperator(typeHandler, value, op, operand);
    }
});

Copilot AI and others added 6 commits April 12, 2026 05:35
…ion"

This reverts commit 972aea7.

Co-authored-by: DanexCodr <216312766+DanexCodr@users.noreply.github.com>
@DanexCodr DanexCodr marked this pull request as ready for review April 12, 2026 05:51
@DanexCodr DanexCodr merged commit 0d2cd50 into main Apr 12, 2026
@DanexCodr DanexCodr deleted the copilot/optimize-naturalarray-o1 branch April 12, 2026 05:51
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.

2 participants