From 07791a8b9f9c25e83ef849e1cea431ed25be7553 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 5 Oct 2026 06:54:21 +0100 Subject: Keep an event's lists in arrays, flat or at their keys, and read a field by key as one (021) - pure_list_arrays: an event's list (never shared, journaled or undone) keeps its items in arrays: FLAT in order, or DENSE at their keys when keyed by small whole numbers. A position asked of a DENSE list makes it FLAT; moves past a few times its items, arrays past 64 MiB, or a third change of form make it a tree. Answers are the tree's; the stored bytes stand for its items in the memory budget whatever it keeps them in. - pure_list_add need not say where an item went: a list no index state refers to is not asked. - A LIST_FIND whose index the next ITEM_GET of its list takes at once is joined to it at load (PLAN_JOINED): pure_list_lookup reads the field by key, at the key in a DENSE list. - test-module arrays_equivalence: beside a tree, every step of a random run (adds, inserts, removes, changes, finds, reads, runs, clears) gives the same answers through every form and change of form. - A search (100,000 nodes, 1,000,000 edges, core only): 187 to 126 ms. --- core/module.h | 1 + 1 file changed, 1 insertion(+) (limited to 'core/module.h') diff --git a/core/module.h b/core/module.h index 80d4460..9562358 100644 --- a/core/module.h +++ b/core/module.h @@ -254,6 +254,7 @@ typedef struct { /* A keyed list: its key field + 1 (0: none). Its items stay in key order * (numbers by value, texts by bytes), each key once, and keys do not change. */ uint8_t state_key[PURE_MODULE_STATES]; + bool state_indexed[PURE_MODULE_STATES]; /* list: an index state refers to it (set at load) */ PureInputShape input[PURE_MODULE_INPUTS]; PureField field[PURE_MODULE_FIELDS]; PureValue initial[PURE_MODULE_STATES]; -- cgit v1.2.3