From 3cc6bc3d8a1d8827519decbf7e084e89110c93f9 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 19 Oct 2026 00:16:56 +0100 Subject: 027's 4f-3b: no fixed count of records or of their fields in all: the header's u16s alone (16 and 128 before); a stored list's record graph (PureLayout) holds a few records itself and more on the heap, 256 at most (an image numbers them in a byte), an image or a checkpoint not written then without room for it; a record's 16 fields kept, the list engine's width (a leaf's columns, a run's columns and narrow cells, the arrays' and packs' columns), to be widened with the lists' shapes sized to their fields; unit tests: 20 records of 10 fields (200 in all), an item of the last appended; a stored list whose six records each hold a list of the next saved and read back after a restart (its graph on the heap); counts: b41 against b40 with batches BFS +0.12%, without BFS -0.09%, the rest within 0.001%; the bank's queries (s40 and s41 in turns, six each) within 0.09% (the first three's in_credit +1.16% its spread: 2.75% between runs of one build); 008 and 027 --- core/module-save.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'core/module-save.h') diff --git a/core/module-save.h b/core/module-save.h index 4ec50a2..44d3b95 100644 --- a/core/module-save.h +++ b/core/module-save.h @@ -79,15 +79,25 @@ uint8_t pure_record_kind(const PureModule *, uint32_t field); * order its list fields first meet them, each its fields' kinds (PURE_CELL_...) and names, and a list field's items' * record by its number here. A module's graph knows each record's number in the module too. */ typedef struct { - unsigned records; - struct { - unsigned count; - uint8_t kinds[PURE_RECORD_FIELDS], items[PURE_RECORD_FIELDS]; - char names[PURE_RECORD_FIELDS][PURE_MODULE_NAME]; - } record[PURE_MODULE_RECORDS]; - uint16_t module_record[PURE_MODULE_RECORDS]; + unsigned count; + uint8_t kinds[PURE_RECORD_FIELDS], items[PURE_RECORD_FIELDS]; + char names[PURE_RECORD_FIELDS][PURE_MODULE_NAME]; +} PureLayoutRecord; +/* Its records in record (a few in few, more on the heap: room of them), at most 256 (a store numbers them in a byte), + * module_record beside them. Begun (pure_layout_begin) before use, done (pure_layout_done) after; never copied. */ +typedef struct { + unsigned records, room; + PureLayoutRecord *record; + uint16_t *module_record; + PureLayoutRecord few[4]; + uint16_t few_records[4]; } PureLayout; -void pure_layout_of(const PureModule *, uint32_t record, PureLayout *out); +enum { PURE_LAYOUT_RECORDS = 256 }; +void pure_layout_begin(PureLayout *); +bool pure_layout_room(PureLayout *, unsigned records); /* false without room, or past PURE_LAYOUT_RECORDS */ +void pure_layout_done(PureLayout *); +/* false: no room, or a graph of more than PURE_LAYOUT_RECORDS records. */ +bool pure_layout_of(const PureModule *, uint32_t record, PureLayout *out); bool pure_layout_same(const PureLayout *, const PureLayout *); /* A list with record's fields, taking from `from` (laid out as from_layout's record 0) each field of the same name and * kind, or a number, a bool and an i64 from each other when the value fits (pure_cell_as), and giving the others their -- cgit v1.2.3