blockdev — playground

A click-and-see-it-work demo of the copy-on-write block device. The Go module is compiled to WebAssembly and runs entirely inside this browser tab — the device, overlay, and snapshot all live in your tab's memory. Reload the page and everything is gone. That's what "in-memory" means.

Single-threaded here, but the library is concurrency-safe: overlay guarded by sync.RWMutex, verified by go test -race.

checking module version…

1. Initialize

blockdev.New(base) — fresh device; base seeded with letters a, b, c, … (block N = byte 'a'+N%26).

2. State

Loading WASM…

3. Actions

Try this flow: the base starts seeded with letters a, b, c, … Write X to block 2 → Snapshot (copy the hex) → Discard (watch the base row stay, overlay disappear) → paste the hex back → Restore (overlay returns, exactly as it was). That's the snapshot / resume story in five clicks.
block with character bd.WriteAt(p, off) — fills the block with 4096 copies of this byte (overlay only; base untouched)
block bd.ReadAt(p, off) — overlay-first, falls through to base; paints the read row red (overlay) or dim (base)
bd.Serialize() — emits only the overlay (changed blocks), hex-fills the textarea below
→ drops the *BlockDevice reference (Go GC reclaims the overlay) and clears the hex box; the base byte slice survives in memory
💾 Copy the hex below before clicking Discard if you want to Restore later. The textarea content is the snapshot blob — just hex-encoded for display, since a textarea can't show raw binary safely. Every two characters = one byte. Each changed block is 4096 + 8 = 4104 bytes = 8208 hex chars, so even one write produces a long string.
→ Copy writes the textarea to your clipboard · Restore calls blockdev.Deserialize(blob, base) to rebuild the device

4. Log

(loading…)