Skip to content

Instantly share code, notes, and snippets.

View matthew-levan's full-sized avatar

Matthew LeVan matthew-levan

  • Walton, KY
  • 23:36 (UTC -04:00)
View GitHub Profile
@matthew-levan
matthew-levan / 2x.md
Created March 28, 2026 01:29
2x Peak Memory Pressure Analysis in Blob Store

2× Peak Memory Pressure Analysis

Root Cause: Clay's Dual Storage

When a 2 GiB file is committed via |commit %base, Clay stores the content atom twice in its Nock-level state:

  1. lat.ran ((map lobe page)) — the content-addressed object store, keyed by SHA-512 hash. Stores [%mime [mite [len atom]]] as a page.
  2. mim.dom ((map path mime)) — the mime cache for unix-mounted desks. Stores
@matthew-levan
matthew-levan / blob-store.md
Last active March 31, 2026 18:35
Blob Store for Very Large Nouns

Blob Store for Very Large Atoms (ml/bob)

1. Overview

Large atoms (> 32 MiB) are stored as content-addressed files in $pier/.urb/bob/<mug>/<seq> instead of being held inline in the loom. A bob atom is an indirect atom whose payload encodes only a (mug, seq) pair; the actual bytes live on disk. The loom holds a small u3a_blob metadata record per unique blob, reference-counted independently from the noun refcount.

@matthew-levan
matthew-levan / mars-urth-ipc-plan .md
Created March 13, 2026 13:44
Shared-Memory IPC for Large Nouns

Design: Shared-Memory IPC for Large Nouns

Problem Summary

When a noun of size N crosses the king-serf boundary, the current system creates ~7 full copies in user-space:

  1. King jam (u3s_jam_xeno): noun → bytes + hash table
  2. Pipe transit: bytes → kernel → bytes
  3. Newt decode memcpy: libuv buf → meat buffer
@matthew-levan
matthew-levan / mars-urth-ipc-analysis.md
Created March 13, 2026 13:16
mars/urth ipc analysis

Mars/Urth IPC Analysis

Architecture

The king (Urth) and serf (Mars) are separate OS processes connected by Unix pipes (stdin/stdout), using the "newt" framing protocol (5-byte header + payload). The loom (noun memory arena) is not shared between processes — every message must be serialized (jammed) on the send side and deserialized (cued) on the receive side.

@matthew-levan
matthew-levan / book-lmdb.md
Created February 5, 2026 00:57
book with lmdb-style double-buffering

Book: Append-Only Event Log

File Layout

book.log is a single flat file with three regions:

Offset 0       Offset 4096    Offset 8192
+-----------+  +-----------+  +-------+-------+-------+-----+
| Header A  |  | Header B  |  | Deed  | Deed  | Deed  | ... |
ASAN after running `=x (bex (bex 38))`
=================================================================
==29975==ERROR: AddressSanitizer: use-after-poison on address 0x72800cdb0000 at pc 0x000100ba6d70 bp 0x00016f337650 sp 0x00016f337648
WRITE of size 8 at 0x72800cdb0000 thread T0
#0 0x100ba6d6c in _alloc_pages palloc.c:322
#1 0x100b92b78 in _imalloc palloc.c:554
#2 0x100b92b24 in u3a_walloc allocate.c:238
#3 0x100bad088 in _ca_take_atom allocate.c:507
#4 0x100baca6c in _ca_take_next_north allocate.c:638
@matthew-levan
matthew-levan / athenian-sunrise.md
Last active September 13, 2024 09:56
Strategic considerations for our Butylic vision

Athenian Sunrise

In architecting the future of the Urbit UX, we must establish strategic principles according to the spirit of the opportunity and corresponding realities. These realities serve as natural limiting factors, in the same way that famous bodybuilder Henry Rollins says about weights in the the gym: "The Iron never lies." In other words, picking up the correct weight (not too heavy, not too light) is the only way we progress. The correct weight is the real weight is the one which fate has dealt us, and which is well within our immediate reach. It is characterized by its limitations with respect to our

@matthew-levan
matthew-levan / building-future-private-computing.md
Last active September 10, 2024 19:13
Building the future of private computing

Building the future of private computing

Onboarding

  • Physical Urbit cards to sell for $10
  • Dead simple "Buy an Urbit" button on urbit.org

An ENS and DNS Name

  • mastex-bintyl.urbit.box (we own urbit.box)
@matthew-levan
matthew-levan / urbit-future-private-computing.md
Last active September 10, 2024 00:39
Urbit: the future of private computing

Let's forget the gawky, warty, pimpled young Urbit of the present, and take a look at one possible fantastic user experience of the future.

Disclaimer: this is not a plan. This is just a dream. But everything in this dream (codename "Butyl") is real and possible and I think it's going to happen.

Onboarding

@matthew-levan
matthew-levan / loom-migrations.md
Last active August 31, 2023 19:58
Loom Migrations

Loom Migration Refactor

I am undertaking a refactor of the pointer compression loom migration. Refactoring this migration (the only "loom migration" we currently have in the repository) will also serve as scaffolding for future loom migrations.

Motivation

Currently, pointer compression is implemented as a feature which depends on a "virtual bits" flag, u3C.vits_w. This flag is set at runtime based