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.
blockdev.New(base) — fresh device; base seeded with letters a, b, c, … (block N = byte 'a'+N%26).
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.
bd.WriteAt(p, off) — fills the block with 4096 copies of this byte (overlay only; base untouched)
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
*BlockDevice reference (Go GC reclaims the overlay) and clears the hex box; the base byte slice survives in memory
blockdev.Deserialize(blob, base) to rebuild the device
(loading…)