From 9f17dd667c3282aa28d6b3961eda28e592961478 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sun, 18 Oct 2026 17:54:16 +0100 Subject: Research 140, 027's stage 3 measured: a board of columns of cards of tags (aup's stored_nested) alike in memory and on a store restarting eight times, every step's fault, states and a view (2,400 snapshots, 54 restarts); killed at the tree's four stages and the log's two, all or nothing; replacement moving nested lists by name at depth; appending into a stored item's list costs about 170 ns an item it already holds (append_cost.c: 42 µs an add on average over the first 500, 738 µs over 8,000), building one by appends quadratic; instruction counts: the first commit's BFS +1.45% with batches and +1.68% without, from branches in the hot steps, gone with the load's internal ops (b29 against b27: BFS 0.000%/+0.034%, the others within 0.008%; the bank's queries -0.25% to +0.22%); what remains (a message's rows holding lists, a list field's .count in a fold, for over xs[i].f); 027's stage 3 as made (the representation chosen against the plan, its cost); 008's wording (kind 5 in images' headers alone); CHECKPOINT's direction row through stage 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- research/experiments/044-specs/append_cost.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 research/experiments/044-specs/append_cost.c (limited to 'research/experiments/044-specs/append_cost.c') diff --git a/research/experiments/044-specs/append_cost.c b/research/experiments/044-specs/append_cost.c new file mode 100644 index 0000000..a3ef0bb --- /dev/null +++ b/research/experiments/044-specs/append_cost.c @@ -0,0 +1,31 @@ +/* Research 140, design 027 stage 3: the cost of appending into a stored list's item's list (aup's check.py BOARD_SOURCE + * compiled, add_card into one column, in memory): ns an add, on average so far, as the list grows. + * cc -O2 -std=c17 -I../../../core append_cost.c ../../../build/libpure.a -lm -pthread -o append_cost + * ./append_cost board.pmod */ +#define _POSIX_C_SOURCE 200809L +#include "module.h" +#include +#include +#include +static double now_ns(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * 1e9 + t.tv_nsec; } +int main(int argc, char **argv) { + PureModule m; char error[160]; + if (pure_module_read(argv[1], &m, error, sizeof(error)) != PURE_OK) { fprintf(stderr, "%s\n", error); return 1; } + PureApp app; + if (pure_app_start(&app, &m, (PureData){0}) != PURE_OK) return 1; + int column = pure_module_input(&m, "add_column"), card = pure_module_input(&m, "add_card"); + pure_app_message(&app, (uint32_t)column, NULL, -1, (PureSpan){(const unsigned char *)"todo", 4}); + unsigned char payload[16]; + double zero = 0; + memcpy(payload, &zero, 8); + memcpy(payload + 8, "card0001", 8); + double start = now_ns(); + for (int n = 1; n <= 8000; ++n) { + if (pure_app_message(&app, (uint32_t)card, NULL, -1, (PureSpan){payload, 16}) != PURE_OK) { fprintf(stderr, "fail at %d\n", n); return 1; } + if (n == 500 || n == 1000 || n == 2000 || n == 4000 || n == 8000) { + double t = now_ns(); + printf("{\"cards\":%d,\"ns_per_add_so_far\":%.0f}\n", n, (t - start) / n); + } + } + return 0; +} -- cgit v1.2.3