summaryrefslogtreecommitdiff
path: root/vere/pkg
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-06 14:35:41 +0700
committerpolwex <polwex@sortug.com>2025-10-06 14:35:41 +0700
commit256376afffe66faa239a6a6aaebb8f68a9c6cbe4 (patch)
tree52f2ea2ba9da38e7edf64bb810708526cdeb14f5 /vere/pkg
parent4a6067863d415e0334b4b61254fab2bd879a6964 (diff)
very stuck
Diffstat (limited to 'vere/pkg')
-rw-r--r--vere/pkg/noun/vortex.c14
-rw-r--r--vere/pkg/vere/jam_bench_compare.c188
-rw-r--r--vere/pkg/vere/jam_compare.c64
-rw-r--r--vere/pkg/vere/solid_cue_bench.c60
4 files changed, 14 insertions, 312 deletions
diff --git a/vere/pkg/noun/vortex.c b/vere/pkg/noun/vortex.c
index 8496307..0d6d1cf 100644
--- a/vere/pkg/noun/vortex.c
+++ b/vere/pkg/noun/vortex.c
@@ -25,11 +25,21 @@ u3v_home* u3v_Home;
u3_noun
u3v_life(u3_noun eve)
{
+ c3_o is_null = u3r_sing(u3_nul, eve);
+ c3_o is_atom = u3a_is_atom(eve);
+ c3_o is_cell = u3du(eve);
+
+ u3l_log("u3v_life: eve=%s (atom=%s cell=%s)",
+ is_null ? "null" : (is_cell ? "cell" : "atom"),
+ is_atom ? "yes" : "no",
+ is_cell ? "yes" : "no");
+
u3_noun lyf = u3nt(2, u3nc(0, 3), u3nc(0, 2));
u3_noun gat = u3n_nock_on(eve, lyf);
u3_noun cor = u3k(u3x_at(7, gat));
u3z(gat);
+ u3l_log("u3v_life: completed successfully");
return cor;
}
@@ -45,14 +55,18 @@ u3v_boot(u3_noun eve)
u3z(len);
}
+ u3l_log("u3v_boot: processing %llu events", (unsigned long long)len_d);
+
{
u3_noun pro = u3m_soft(0, u3v_life, eve);
if ( u3_blip != u3h(pro) ) {
+ u3l_log("u3v_boot: FAILED - u3v_life returned error");
u3z(pro);
return c3n;
}
+ u3l_log("u3v_boot: SUCCESS - kernel built");
u3z(u3A->roc);
u3A->roc = u3k(u3t(pro));
u3A->eve_d = len_d;
diff --git a/vere/pkg/vere/jam_bench_compare.c b/vere/pkg/vere/jam_bench_compare.c
deleted file mode 100644
index baad686..0000000
--- a/vere/pkg/vere/jam_bench_compare.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/// @file
-/// Jam/cue benchmarks matching OCaml structure for direct comparison
-
-#include "noun.h"
-#include "vere.h"
-#include <stdio.h>
-#include <sys/time.h>
-
-static void _setup(void) {
- u3m_boot_lite(1 << 24);
-}
-
-static double get_time(void) {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_sec + tv.tv_usec / 1000000.0;
-}
-
-static void benchmark(const char* name, int iterations, void (*f)(void)) {
- // Warmup
- int warmup = iterations / 10;
- if (warmup > 100) warmup = 100;
- for (int i = 0; i < warmup; i++) {
- f();
- }
-
- // Actual benchmark
- double start = get_time();
- for (int i = 0; i < iterations; i++) {
- f();
- }
- double elapsed = get_time() - start;
-
- double avg = elapsed / iterations;
- double total = elapsed;
- fprintf(stdout, "%-40s %d iters: avg=%.6f total=%.6f\n",
- name, iterations, avg, total);
-}
-
-// Test data
-static u3_noun test_atom_small;
-static u3_noun test_atom_large;
-static u3_noun test_cell;
-static u3_noun test_tree;
-static u3_noun test_list;
-static u3_noun test_deep;
-static c3_y* jam_small_bytes;
-static c3_d jam_small_len;
-static c3_y* jam_tree_bytes;
-static c3_d jam_tree_len;
-
-// Benchmark functions
-static void bench_jam_cue_small(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_atom_small, &len, &bytes);
- u3_noun result = u3s_cue_xeno(len, bytes);
- c3_free(bytes);
- u3z(result);
-}
-
-static void bench_jam_cue_large(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_atom_large, &len, &bytes);
- u3_noun result = u3s_cue_xeno(len, bytes);
- c3_free(bytes);
- u3z(result);
-}
-
-static void bench_jam_cue_cell(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_cell, &len, &bytes);
- u3_noun result = u3s_cue_xeno(len, bytes);
- c3_free(bytes);
- u3z(result);
-}
-
-static void bench_jam_cue_tree(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_tree, &len, &bytes);
- u3_noun result = u3s_cue_xeno(len, bytes);
- c3_free(bytes);
- u3z(result);
-}
-
-static void bench_jam_cue_list(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_list, &len, &bytes);
- u3_noun result = u3s_cue_xeno(len, bytes);
- c3_free(bytes);
- u3z(result);
-}
-
-static void bench_jam_cue_deep(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_deep, &len, &bytes);
- u3_noun result = u3s_cue_xeno(len, bytes);
- c3_free(bytes);
- u3z(result);
-}
-
-static void bench_jam_only_small(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_atom_small, &len, &bytes);
- c3_free(bytes);
-}
-
-static void bench_jam_only_tree(void) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(test_tree, &len, &bytes);
- c3_free(bytes);
-}
-
-static void bench_cue_only_small(void) {
- u3_noun result = u3s_cue_xeno(jam_small_len, jam_small_bytes);
- u3z(result);
-}
-
-static void bench_cue_only_tree(void) {
- u3_noun result = u3s_cue_xeno(jam_tree_len, jam_tree_bytes);
- u3z(result);
-}
-
-int main(int argc, char* argv[]) {
- _setup();
-
- // Create test data matching OCaml benchmarks
- test_atom_small = 42;
- test_atom_large = u3i_chubs(1, (c3_d[]){1ULL << 63});
- test_cell = u3nc(1, 2);
-
- // Balanced tree: [[1 2] [3 4]] [[5 6] [7 8]]
- test_tree = u3nc(
- u3nc(u3nc(1, 2), u3nc(3, 4)),
- u3nc(u3nc(5, 6), u3nc(7, 8))
- );
-
- // List structure: [20 [19 [18 ... [1 0]]]]
- test_list = 0;
- for (int i = 1; i <= 20; i++) {
- test_list = u3nc(i, test_list);
- }
-
- // Deep nesting: [100 [99 [98 ... [1 0]]]]
- test_deep = 0;
- for (int i = 1; i <= 100; i++) {
- test_deep = u3nc(i, test_deep);
- }
-
- // Pre-jam for cue-only benchmarks
- u3s_jam_xeno(test_atom_small, &jam_small_len, &jam_small_bytes);
- u3s_jam_xeno(test_tree, &jam_tree_len, &jam_tree_bytes);
-
- fprintf(stdout, "========================================\n");
- fprintf(stdout, "Jam/Cue Serialization Benchmarks (C)\n");
- fprintf(stdout, "========================================\n\n");
-
- fprintf(stdout, "Round-trip benchmarks:\n");
- benchmark("jam/cue small atom (42)", 100000, bench_jam_cue_small);
- benchmark("jam/cue large atom (2^64)", 10000, bench_jam_cue_large);
- benchmark("jam/cue simple cell [1 2]", 100000, bench_jam_cue_cell);
- benchmark("jam/cue balanced tree (depth 3)", 50000, bench_jam_cue_tree);
- benchmark("jam/cue list structure (20 elements)", 10000, bench_jam_cue_list);
- benchmark("jam/cue deep nesting (100 levels)", 1000, bench_jam_cue_deep);
-
- fprintf(stdout, "\nJam-only benchmarks:\n");
- benchmark("jam only (small atom)", 100000, bench_jam_only_small);
- benchmark("jam only (balanced tree)", 50000, bench_jam_only_tree);
-
- fprintf(stdout, "\nCue-only benchmarks:\n");
- benchmark("cue only (small atom)", 100000, bench_cue_only_small);
- benchmark("cue only (balanced tree)", 50000, bench_cue_only_tree);
-
- fprintf(stdout, "\n========================================\n");
-
- // Cleanup
- c3_free(jam_small_bytes);
- c3_free(jam_tree_bytes);
-
- return 0;
-}
diff --git a/vere/pkg/vere/jam_compare.c b/vere/pkg/vere/jam_compare.c
deleted file mode 100644
index bea8032..0000000
--- a/vere/pkg/vere/jam_compare.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/// @file
-/// Outputs jam encodings for comparison with OCaml
-
-#include "noun.h"
-#include "vere.h"
-#include <stdio.h>
-
-static void _setup(void) {
- u3m_boot_lite(1 << 24);
-}
-
-static void print_hex(c3_y* bytes, c3_d len) {
- for (c3_d i = 0; i < len; i++) {
- fprintf(stdout, "%02x", bytes[i]);
- }
- fprintf(stdout, "\n");
-}
-
-static void jam_and_print(const char* label, u3_noun noun) {
- c3_d len;
- c3_y* bytes;
- u3s_jam_xeno(noun, &len, &bytes);
-
- fprintf(stdout, "%s: ", label);
- print_hex(bytes, len);
-
- c3_free(bytes);
-}
-
-int main(int argc, char* argv[]) {
- _setup();
-
- fprintf(stdout, "# C jam outputs (hex)\n");
-
- // Simple atoms
- jam_and_print("0", 0);
- jam_and_print("1", 1);
- jam_and_print("2", 2);
- jam_and_print("42", 42);
- jam_and_print("255", 255);
- jam_and_print("256", 256);
-
- // Simple cells
- jam_and_print("[1 2]", u3nc(1, 2));
- jam_and_print("[0 0]", u3nc(0, 0));
- jam_and_print("[42 43]", u3nc(42, 43));
-
- // Nested cells
- jam_and_print("[[1 2] 3]", u3nc(u3nc(1, 2), 3));
- jam_and_print("[1 [2 3]]", u3nc(1, u3nc(2, 3)));
-
- // Balanced tree
- jam_and_print("[[1 2] [3 4]]",
- u3nc(u3nc(1, 2), u3nc(3, 4)));
-
- // Larger tree
- jam_and_print("[[[1 2] [3 4]] [[5 6] [7 8]]]",
- u3nc(
- u3nc(u3nc(1, 2), u3nc(3, 4)),
- u3nc(u3nc(5, 6), u3nc(7, 8))
- ));
-
- return 0;
-}
diff --git a/vere/pkg/vere/solid_cue_bench.c b/vere/pkg/vere/solid_cue_bench.c
deleted file mode 100644
index 0be36ad..0000000
--- a/vere/pkg/vere/solid_cue_bench.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/// Benchmark cue performance on solid pill
-
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "noun.h"
-#include "ur/ur.h"
-#include "vere.h"
-
-static double get_time(void) {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_sec + tv.tv_usec / 1000000.0;
-}
-
-int main(int argc, char* argv[]) {
- const char* pill_path = argc > 1 ? argv[1] : "../../../ocaml/solid.pill";
-
- // Read pill file
- FILE* f = fopen(pill_path, "rb");
- if (!f) {
- printf("Error: cannot open %s\n", pill_path);
- return 1;
- }
-
- struct stat st;
- fstat(fileno(f), &st);
- c3_d len_d = st.st_size;
-
- c3_y* byt_y = malloc(len_d);
- fread(byt_y, 1, len_d, f);
- fclose(f);
-
- printf("Pill: %s (%.1f MB)\n", pill_path, len_d / 1024.0 / 1024.0);
- printf("Starting cue benchmark...\n\n");
-
- // Initialize Urbit runtime
- u3C.wag_w |= u3o_hashless;
- u3m_boot_lite(1 << 26); // 64 MB loom
-
- // Benchmark cue
- double start = get_time();
- u3_cue_xeno* sil_u = u3s_cue_xeno_init_with(ur_fib27, ur_fib28);
- u3_weak pil = u3s_cue_xeno_with(sil_u, len_d, byt_y);
- double elapsed = get_time() - start;
-
- if (u3_none == pil) {
- printf("Error: cue failed\n");
- return 1;
- }
-
- u3s_cue_xeno_done(sil_u);
-
- printf("✓ Cue completed in %.4f seconds\n", elapsed);
- printf(" Throughput: %.2f MB/s\n", (len_d / 1024.0 / 1024.0) / elapsed);
-
- free(byt_y);
- return 0;
-}