From 256376afffe66faa239a6a6aaebb8f68a9c6cbe4 Mon Sep 17 00:00:00 2001 From: polwex Date: Mon, 6 Oct 2025 14:35:41 +0700 Subject: very stuck --- vere/.github/CODEOWNERS | 6 + vere/.github/pull_request_template.md | 1 + vere/.github/workflows/develop.yml | 28 ++++ vere/.github/workflows/docker-once.yml | 11 ++ vere/.github/workflows/docker-shared.yml | 73 +++++++++++ vere/.github/workflows/feature.yml | 19 +++ vere/.github/workflows/master.yml | 29 ++++ vere/.github/workflows/next.yml | 22 ++++ vere/.github/workflows/once.yml | 12 ++ vere/.github/workflows/release.yml | 28 ++++ vere/.github/workflows/shared.yml | 219 +++++++++++++++++++++++++++++++ vere/build.zig | 20 --- vere/pkg/noun/vortex.c | 14 ++ vere/pkg/vere/jam_bench_compare.c | 188 -------------------------- vere/pkg/vere/jam_compare.c | 64 --------- vere/pkg/vere/solid_cue_bench.c | 60 --------- 16 files changed, 462 insertions(+), 332 deletions(-) create mode 100644 vere/.github/CODEOWNERS create mode 100644 vere/.github/pull_request_template.md create mode 100644 vere/.github/workflows/develop.yml create mode 100644 vere/.github/workflows/docker-once.yml create mode 100644 vere/.github/workflows/docker-shared.yml create mode 100644 vere/.github/workflows/feature.yml create mode 100644 vere/.github/workflows/master.yml create mode 100644 vere/.github/workflows/next.yml create mode 100644 vere/.github/workflows/once.yml create mode 100644 vere/.github/workflows/release.yml create mode 100644 vere/.github/workflows/shared.yml delete mode 100644 vere/pkg/vere/jam_bench_compare.c delete mode 100644 vere/pkg/vere/jam_compare.c delete mode 100644 vere/pkg/vere/solid_cue_bench.c (limited to 'vere') diff --git a/vere/.github/CODEOWNERS b/vere/.github/CODEOWNERS new file mode 100644 index 0000000..147aa59 --- /dev/null +++ b/vere/.github/CODEOWNERS @@ -0,0 +1,6 @@ +# For more information on how CODEOWNERS work, see +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners. + +# Default owner for everything in the repo. Matches farther down in the file +# will override this default. +* @urbit/runtime diff --git a/vere/.github/pull_request_template.md b/vere/.github/pull_request_template.md new file mode 100644 index 0000000..01e58ed --- /dev/null +++ b/vere/.github/pull_request_template.md @@ -0,0 +1 @@ +Resolves # diff --git a/vere/.github/workflows/develop.yml b/vere/.github/workflows/develop.yml new file mode 100644 index 0000000..36aedc0 --- /dev/null +++ b/vere/.github/workflows/develop.yml @@ -0,0 +1,28 @@ +name: Push to develop + +on: + push: + branches: + - develop + paths: + - 'build.zig' + - 'build.zig.zon' + - 'ext/**' + - '!ext/**.md' + - 'pkg/**' + - '.github/workflows/**.yml' + - '*.sh' + +jobs: + urbit: + uses: ./.github/workflows/shared.yml + with: + pace: 'edge' + upload: true + secrets: inherit + + docker: + uses: ./.github/workflows/docker-shared.yml + with: + pace: 'edge' + secrets: inherit diff --git a/vere/.github/workflows/docker-once.yml b/vere/.github/workflows/docker-once.yml new file mode 100644 index 0000000..2f17659 --- /dev/null +++ b/vere/.github/workflows/docker-once.yml @@ -0,0 +1,11 @@ +name: Deploy to DockerHub once + +on: + workflow_dispatch + +jobs: + docker: + uses: ./.github/workflows/docker-shared.yml + with: + pace: 'edge' + secrets: inherit diff --git a/vere/.github/workflows/docker-shared.yml b/vere/.github/workflows/docker-shared.yml new file mode 100644 index 0000000..a2a0eb7 --- /dev/null +++ b/vere/.github/workflows/docker-shared.yml @@ -0,0 +1,73 @@ +name: docker + +on: + workflow_call: + inputs: + pace: + description: 'Release pace' + type: string + default: 'edge' + required: false + +jobs: + urbit: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + + - uses: mlugg/setup-zig@v1 + with: + version: 0.14.0 + + # + # BUILD + # + + - name: Build binary + id: build + run: | + zig build \ + -Dtarget=x86_64-linux-musl \ + -Doptimize=ReleaseFast \ + -Dpace=${{inputs.pace}} \ + --summary all + + cp zig-out/x86_64-linux-musl/urbit docker/. + + echo version=v$(sed -nr 's/#define URBIT_VERSION "(.*)"/\1/p' zig-out/include/version.h) >> $GITHUB_OUTPUT + + # + # UPLOAD TO DOCKER + # + + - uses: docker/docker-login-action@v1.8.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - uses: christian-korneck/update-container-description-action@v1 + env: + DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASS: ${{ secrets.DOCKERHUB_TOKEN }} + with: + destination_container_repo: ${{ secrets.DOCKERHUB_USERNAME }}/vere + provider: dockerhub + short_description: 'Urbit: a clean-slate OS and network for the 21st century' + readme_file: 'docker/README.md' + + - name: Build and push + if: ${{ inputs.pace != 'live' }} + uses: docker/build-push-action@v6 + with: + push: true + context: docker + tags: tloncorp/vere:${{ steps.build.outputs.version }},tloncorp/vere:${{ inputs.pace }} + + - name: Build and push live + if: ${{ inputs.pace == 'live' }} + uses: docker/build-push-action@v6 + with: + push: true + context: docker + tags: tloncorp/vere:latest diff --git a/vere/.github/workflows/feature.yml b/vere/.github/workflows/feature.yml new file mode 100644 index 0000000..d78b911 --- /dev/null +++ b/vere/.github/workflows/feature.yml @@ -0,0 +1,19 @@ +name: Feature pull request + +on: + pull_request: + paths: + - 'build.zig' + - 'build.zig.zon' + - 'ext/**' + - '!ext/**.md' + - 'pkg/**' + - '.github/workflows/**.yml' + - '*.sh' + +jobs: + urbit: + uses: ./.github/workflows/shared.yml + with: + pace: 'edge' + upload: false diff --git a/vere/.github/workflows/master.yml b/vere/.github/workflows/master.yml new file mode 100644 index 0000000..02a2b84 --- /dev/null +++ b/vere/.github/workflows/master.yml @@ -0,0 +1,29 @@ +name: Push to master + +on: + push: + branches: + - master + paths: + - 'build.zig' + - 'build.zig.zon' + - 'ext/**' + - '!ext/**.md' + - 'pkg/**' + - '.github/workflows/**.yml' + - '*.sh' + +jobs: + urbit: + uses: ./.github/workflows/shared.yml + with: + pace: 'live' + upload: true + fake_tests: false + secrets: inherit + + docker: + uses: ./.github/workflows/docker-shared.yml + with: + pace: 'live' + secrets: inherit diff --git a/vere/.github/workflows/next.yml b/vere/.github/workflows/next.yml new file mode 100644 index 0000000..71738ad --- /dev/null +++ b/vere/.github/workflows/next.yml @@ -0,0 +1,22 @@ +name: Push to next/kelvin/* + +on: + push: + branches: + - 'next/kelvin/*' + paths: + - 'build.zig' + - 'build.zig.zon' + - 'ext/**' + - '!ext/**.md' + - 'pkg/**' + - '.github/workflows/**.yml' + - '*.sh' + +jobs: + urbit: + uses: ./.github/workflows/shared.yml + with: + upload: true + next: ${{ github.ref_name }} + secrets: inherit diff --git a/vere/.github/workflows/once.yml b/vere/.github/workflows/once.yml new file mode 100644 index 0000000..1081180 --- /dev/null +++ b/vere/.github/workflows/once.yml @@ -0,0 +1,12 @@ +name: Deploy once + +on: + workflow_dispatch + +jobs: + urbit: + uses: ./.github/workflows/shared.yml + with: + pace: 'once' + upload: true + secrets: inherit diff --git a/vere/.github/workflows/release.yml b/vere/.github/workflows/release.yml new file mode 100644 index 0000000..ca4a907 --- /dev/null +++ b/vere/.github/workflows/release.yml @@ -0,0 +1,28 @@ +name: Push to release + +on: + push: + branches: + - release + paths: + - 'build.zig' + - 'build.zig.zon' + - 'ext/**' + - '!ext/**.md' + - 'pkg/**' + - '.github/workflows/**.yml' + - '*.sh' + +jobs: + urbit: + uses: ./.github/workflows/shared.yml + with: + pace: 'soon' + upload: true + secrets: inherit + + docker: + uses: ./.github/workflows/docker-shared.yml + with: + pace: 'soon' + secrets: inherit diff --git a/vere/.github/workflows/shared.yml b/vere/.github/workflows/shared.yml new file mode 100644 index 0000000..e13506e --- /dev/null +++ b/vere/.github/workflows/shared.yml @@ -0,0 +1,219 @@ +name: shared + +on: + workflow_call: + inputs: + pace: + description: 'Release pace' + type: string + default: 'edge' + required: false + upload: + description: 'Upload binaries to GCP' + type: boolean + default: false + required: false + fake_tests: + description: 'Run fake ship tests' + type: boolean + default: true + required: false + next: + description: 'Next Kelvin version branch name' + type: string + default: null + required: false + secrets: + GCP_CREDENTIALS: + required: false + GCP_PROJECT: + required: false + +env: + UPLOAD_BASE: bootstrap.urbit.org/vere + GH_TOKEN: ${{ github.token }} + +jobs: + urbit: + strategy: + fail-fast: false + + runs-on: ubuntu-22.04 + + steps: + # + # BUILD AND TEST + # + - uses: actions/checkout@v3 + + - name: Set swap space + run: | + echo "Memory and swap:" + free -h + echo + swapon --show + echo + + export SWAP_FILE=$(swapon --show=NAME | tail -n 1) + if test -z "${SWAP_FILE}"; then + export SWAP_FILE=/swapfile + else + sudo swapoff -a + sudo rm "${SWAP_FILE}" + fi + sudo fallocate -l 10G "${SWAP_FILE}" + sudo chmod 600 "${SWAP_FILE}" + sudo mkswap "${SWAP_FILE}" + sudo swapon "${SWAP_FILE}" + + echo "Memory and swap:" + free -h + echo + swapon --show + echo + + - uses: mlugg/setup-zig@v2 + with: + version: 0.14.1 + + - name: Build binaries + run: | + if [[ "${{ inputs.pace }}" == "live" ]]; then + zig build \ + -Dall \ + -Drelease \ + --summary all + else + zig build \ + -Dall \ + -Doptimize=ReleaseFast \ + -Dpace=${{inputs.pace}} \ + --summary all + fi + - name: Run unit tests + run: | + zig build \ + ur-test ent-test \ + hashtable-test jets-test \ + nock-test retrieve-test \ + serial-test ames-test \ + pact-test equality-test \ + boot-test newt-test \ + vere-noun-test unix-test \ + benchmarks \ + -Doptimize=ReleaseFast \ + -Dpace=${{inputs.pace}} \ + --summary all + + - name: Build test binary + if: ${{ inputs.fake_tests }} + run: | + zig build \ + -Doptimize=ReleaseFast \ + -Dpace=${{inputs.pace}} \ + -Dbinary-name=urbit-test \ + -Dcpu-dbg \ + -Dmem-dbg \ + -Dc3dbg \ + -Dsnapshot-validation \ + --summary all + + - name: Boot fake ship + if: ${{ inputs.fake_tests }} + env: + URBIT_BINARY: "zig-out/x86_64-linux-musl/urbit-test" + run: ./boot-fake-ship.sh + + - name: Run fake ship tests + if: ${{ inputs.fake_tests }} + env: + URBIT_BINARY: "zig-out/x86_64-linux-musl/urbit-test" + run: ./test-fake-ship.sh + + # + # UPLOAD TO GCP + # + + - uses: google-github-actions/auth@v1 + if: ${{ inputs.upload }} + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS }} + + - uses: google-github-actions/setup-gcloud@v1 + if: ${{ inputs.upload }} + with: + project_id: ${{ secrets.GCP_PROJECT }} + + - name: Upload binary to bootstrap.urbit.org + if: ${{ inputs.upload }} + run: | + sha_version=$(sed -nr 's/#define URBIT_VERSION "(.*)"/\1/p' zig-out/include/version.h) + declare -a targets=( + "aarch64-linux-musl linux-aarch64" + "aarch64-macos-none macos-aarch64" + "x86_64-linux-musl linux-x86_64" + "x86_64-macos-none macos-x86_64" + ) + for t in "${targets[@]}" + do + IFS=' ' read zig_target target <<< "${t}" + urbit_static=$GITHUB_WORKSPACE/zig-out/${zig_target}/urbit + if ${{ inputs.next != null }}; then + next=$(echo "${{ inputs.next }}" | sed 's/[^0-9]//g') + dest="gs://${UPLOAD_BASE}/next/kelvin/${next}/v${sha_version}/vere-v${sha_version}-${target}" + else + dest="gs://${UPLOAD_BASE}/${{ inputs.pace }}/v${sha_version}/vere-v${sha_version}-${target}" + fi + + args="" + # We never overwrite a binary deployed to the "live" train, but we do + # overwrite same-versioned binaries deployed to the "soon" and "edge" + # trains. + if [[ "${{ inputs.pace }}" == "live" ]]; then + gsutil cp -n "${urbit_static}" "$dest" + else + gsutil cp "${urbit_static}" "$dest" + fi + exitcode=$? + + ([ $exitcode -eq 0 ] && echo "upload to $dest complete.") || + (echo "upload to $dest failed." && exit $exitcode); + done + + upload-version-string: + name: Upload latest deployed version string to GCP + runs-on: ubuntu-latest + needs: [urbit] + if: inputs.upload + steps: + - uses: actions/checkout@v3 + + - uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS }} + + - uses: google-github-actions/setup-gcloud@v1 + with: + project_id: ${{ secrets.GCP_PROJECT }} + + - name: Upload latest deployed version string to GCP + run: | + echo "${{ inputs.pace }}" > ./PACE + printf $(sed -nr 's/const VERSION = "(.*)"\;/\1/p' build.zig)-%.10s $(git rev-parse HEAD) > ./VERSION + + if ${{ inputs.next != null }}; then + next=$(echo "${{ inputs.next }}" | sed 's/[^0-9]//g') + target="gs://${UPLOAD_BASE}/next/kelvin/${next}/last" + else + target="gs://${UPLOAD_BASE}/${{ inputs.pace }}/last" + fi + + # We don't use -n here because we want to overwrite the version + # string. + gsutil cp ./VERSION "$target" + exitcode=$? + + [ $exitcode -eq 0 ] && + echo "Upload to $target completed successfully." || + echo "Upload to $target failed."; + exit $exitcode diff --git a/vere/build.zig b/vere/build.zig index def6feb..66318a0 100644 --- a/vere/build.zig +++ b/vere/build.zig @@ -627,16 +627,6 @@ fn buildBinary( .file = "pkg/vere/boot_tests.c", .deps = vere_test_deps, }, - .{ - .name = "solid-cue-bench", - .file = "pkg/vere/solid_cue_bench.c", - .deps = vere_test_deps, - }, - .{ - .name = "examine-solid", - .file = "../ocaml/test/examine_solid_structure.c", - .deps = vere_test_deps, - }, .{ .name = "newt-test", .file = "pkg/vere/newt_tests.c", @@ -657,16 +647,6 @@ fn buildBinary( .file = "pkg/vere/benchmarks.c", .deps = vere_test_deps, }, - .{ - .name = "jam-compare", - .file = "pkg/vere/jam_compare.c", - .deps = vere_test_deps, - }, - .{ - .name = "jam-bench-compare", - .file = "pkg/vere/jam_bench_compare.c", - .deps = vere_test_deps, - }, .{ .name = "pact-test", .file = "pkg/vere/io/mesa/pact_test.c", 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 -#include - -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 - -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 -#include -#include -#include -#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; -} -- cgit v1.2.3