aboutsummaryrefslogtreecommitdiffstats
path: root/research/experiments/044-specs
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-18 17:54:16 +0100
committereunhhu <[email protected]>2026-10-18 17:54:16 +0100
commit9f17dd667c3282aa28d6b3961eda28e592961478 (patch)
treedb954434bdfde3186a06192f1b7ae4e93c44453c /research/experiments/044-specs
parentd5f0cac74721863a91b0a799256b62c0b7b2a3c1 (diff)
downloadpure-9f17dd667c3282aa28d6b3961eda28e592961478.tar.gz
pure-9f17dd667c3282aa28d6b3961eda28e592961478.zip
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
Diffstat (limited to 'research/experiments/044-specs')
-rw-r--r--research/experiments/044-specs/2026-10-18-stage3-append.jsonl5
-rw-r--r--research/experiments/044-specs/append_cost.c31
2 files changed, 36 insertions, 0 deletions
diff --git a/research/experiments/044-specs/2026-10-18-stage3-append.jsonl b/research/experiments/044-specs/2026-10-18-stage3-append.jsonl
new file mode 100644
index 0000000..cd60baf
--- /dev/null
+++ b/research/experiments/044-specs/2026-10-18-stage3-append.jsonl
@@ -0,0 +1,5 @@
+{"cards":500,"ns_per_add_so_far":42451}
+{"cards":1000,"ns_per_add_so_far":84048}
+{"cards":2000,"ns_per_add_so_far":170537}
+{"cards":4000,"ns_per_add_so_far":348505}
+{"cards":8000,"ns_per_add_so_far":738448}
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 <stdio.h>
+#include <string.h>
+#include <time.h>
+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;
+}