Skip to content

feat: Extract constant array and slice literals as single data-carrying builtins - #312

Open
TomAFrench wants to merge 2 commits into
reilabs:mainfrom
noir-lang:tf/fast-array-literals
Open

feat: Extract constant array and slice literals as single data-carrying builtins#312
TomAFrench wants to merge 2 commits into
reilabs:mainfrom
noir-lang:tf/fast-array-literals

Conversation

@TomAFrench

Copy link
Copy Markdown

An n-element array literal previously extracted to n nested letIns feeding mkArray, so every tactic pass over the goal was linear in n and steps' per-statement machinery made proofs about large arrays super-quadratic (256 elements: ~2 minutes and 5GB; 512: stack overflow). The nesting also made extracted files above ~256 elements fail to elaborate at default recursion limits.

All-literal #_mkArray/#_mkVector calls now elaborate to one callBuiltin of Builtin.mkValArray/mkValVector, with the element values hoisted into an auxiliary List definition (chunked appends keep nesting bounded at any size). Goals about a table then contain a single shallow constant, so proof cost is independent of the array length: a 1024-element table spec now costs ~1s instead of failing outright. Arrays with any non-constant element keep the existing path.

…ltins

An n-element array literal previously extracted to n nested letIns feeding
mkArray, so every tactic pass over the goal was linear in n and steps'
per-statement machinery made proofs about large arrays super-quadratic
(256 elements: ~2 minutes and 5GB; 512: stack overflow). The nesting also
made extracted files above ~256 elements fail to elaborate at default
recursion limits.

All-literal #_mkArray/#_mkVector calls now elaborate to one callBuiltin of
Builtin.mkValArray/mkValVector, with the element values hoisted into an
auxiliary List definition (chunked appends keep nesting bounded at any
size). Goals about a table then contain a single shallow constant, so
proof cost is independent of the array length: a 1024-element table spec
now costs ~1s instead of failing outright. Arrays with any non-constant
element keep the existing path.
Add inline explanations to each piece of the mkValArray/mkValVector
pipeline: the length-proof construction in valArray, the shape of the
data-carrying builtins, the reducible Tp projections and their role in
unification, the literal-hoisting rewrite in the elaborator, and the
closing terms emitted by the steps tactic.
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