Skip to content

Commit 51f270b

Browse files
Intern addresses as &[G; 32] to cut kernel FFT cost (#417)
Replace the by-value `[G; 32]` address type with `type Addr = &[G; 32]`. Aiur `store` content-dedups structurally equal arrays to one canonical pointer, so address equality reduces to pointer subtraction and every function carrying addresses drops 31 columns per address argument. `lake exe kernel String.Internal.append`: total FFT 2515875651 -> 2153021841 (-14.4%), total width 48210 -> 37860. ixvm test suite: 283 pass, 0 fail.
1 parent 5006598 commit 51f270b

15 files changed

Lines changed: 589 additions & 584 deletions

Ix/IxVM.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ def entrypoints := ⟦
5050
-- in `k_consts`/`addrs` so the target's own `whnf`/`infer` can
5151
-- resolve `Const` refs; the IOBuffer payload doesn't shrink.
5252
pub fn kernel_check_test(target_addr: [G; 32], check_deps: G) {
53-
let (k_consts, addrs) = ingress_with_primitives(target_addr);
53+
let target = store(target_addr);
54+
let (k_consts, addrs) = ingress_with_primitives(target);
5455
match check_deps {
5556
0 =>
56-
let target_pos = find_addr_idx(target_addr, addrs, 0);
57+
let target_pos = find_addr_idx(target, addrs, 0);
5758
let ci = load(list_lookup(k_consts, target_pos));
5859
check_const(ci, target_pos, k_consts, addrs),
5960
_ => check_all(k_consts, k_consts, addrs),

Ix/IxVM/Convert.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def convert := ⟦
3838
CKDefn(Definition, G),
3939
CKAxio(Axiom),
4040
CKQuot(Quotient),
41-
CKRecr(Recursor, List‹G›, [G; 32]),
42-
CKIndc(Inductive, List‹G›, [G; 32]),
41+
CKRecr(Recursor, List‹G›, Addr),
42+
CKIndc(Inductive, List‹G›, Addr),
4343
CKCtor(Constructor, G)
4444
}
4545

@@ -281,7 +281,7 @@ def convert := ⟦
281281
}
282282

283283
fn convert_recursor(r: Recursor, ctx: ConvertCtx, rule_ctor_idxs: List‹G›,
284-
block_addr: [G; 32]) -> KConstantInfo {
284+
block_addr: Addr) -> KConstantInfo {
285285
match r {
286286
Recursor.Mk(k, is_unsafe, lvls, params, indices, motives, minors, &typ, rules) =>
287287
let ktyp = ctx_convert_expr(typ, ctx);
@@ -294,7 +294,7 @@ def convert := ⟦
294294
}
295295

296296
fn convert_inductive(ind: Inductive, ctx: ConvertCtx, ctor_idxs: List‹G›,
297-
block_addr: [G; 32]) -> KConstantInfo {
297+
block_addr: Addr) -> KConstantInfo {
298298
match ind {
299299
Inductive.Mk(is_rec, is_refl, is_unsafe, lvls, params, indices, nested, &typ, _) =>
300300
let ktyp = ctx_convert_expr(typ, ctx);

Ix/IxVM/Core.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def core := ⟦
1818
None
1919
}
2020

21+
-- Interned 32-element address (blake3 content hash). Aiur `store`
22+
-- content-dedups structurally-equal arrays to one canonical pointer,
23+
-- so address equality reduces to pointer subtraction.
24+
type Addr = &[G; 32]
25+
2126
fn list_length‹T›(list: List‹T›) -> G {
2227
match load(list) {
2328
ListNode.Nil => 0,

0 commit comments

Comments
 (0)