Guides
Sample projects
Runnable demos in the repository and what each one shows.
Each demo is in the repository and runs from a checkout.
The server demos serve the same 336,776 flight records (data/flights.jsonl, nycflights13) and switch between
a plain array or list (MODE=baseline) and a packmem table (MODE=packmem, the default), so you can compare the
two on your machine. Their measurements are in
demos/README.md, with the raw results in
demos/bench/results/.
Build the Node addon once before the Node demos (cd node && npm run build), and the Python wheel before the
FastAPI demo (see Install). The flights file comes from
benchmarks/fetch_data.py, which needs the nycflights13 Python package:
pip install nycflights13
mkdir -p data && (cd data && python ../benchmarks/fetch_data.py)Express
demos/express: an Express 5 server with filtered pages, group-bys, a summary and a full export. The export
answers Accept: application/vnd.packmem with packed bytes through packmem/http, and JSON otherwise.
cd demos/express && npm install && npm start # port 3001; npm run start:baseline to compareShows: server memory at rest and under load against an array of objects, and JSON written from the columns.
Next.js
demos/nextjs: the same API as route handlers, a dashboard at /, and /browse, a client page that fetches the
export as packed bytes, opens it with packmem/wasm and scrolls it with useRows.
cd demos/nextjs && npm install && npm run build && npm start # port 3002Shows: serverExternalPackages, respond in a route handler, serving the .wasm file, and a virtualized list
that holds objects only for the rows on screen. The Next.js guide walks through it.
Log viewer
demos/log-viewer: a Next.js app that sends 1,000,000 generated log records to the browser and scrolls through
them, with respond on the server and useTable and useRows in the page. A switch loads the same rows as JSON
with res.json(), so the two can be compared on one page: time until usable, the browser's JS heap, and bytes over
the network. The records come from a seeded generator, so nothing is downloaded.
cd demos/log-viewer && npm install && npm run build && npm start # packmem from npm; http://localhost:3000, in ChromeShows: the whole browser path with the two hooks, and where packed bytes pay off and where they do not. Its README has one run's figures and notes on deploying to Vercel.
FastAPI
demos/fastapi: the same routes in Python, including the byte export.
cd demos/fastapi
uv venv .venv && uv pip install --python .venv/bin/python -r requirements.txt ../../python/dist/packmem-*.whl
MODE=packmem .venv/bin/uvicorn app:app --port 3003Shows: a Python server's memory with a list of dicts against a packmem table, and iter_json streaming.
All three servers can load from Postgres instead of the file: set FLIGHTS_PG_URL (setup in the demos README).
Cloudflare Workers
demos/workers: a synthetic web log held in a Worker through packmem/wasm, with /stats (a filtered group count
and sum) and /export (matching rows streamed as JSON). MODE=plain holds the same rows as objects.
cd demos/workers && npm install
npx wrangler dev # http://localhost:8787/stats?country=SE&path=/api
node bench.mjs # both modes at 200,000 and 1,000,000 rowsShows: initSync with an imported .wasm module, and packmem inside a 128 MB isolate.
Fine-tuning data loader
demos/finetune-loader: a PyTorch DataLoader over LLaVA instruction data with the annotations held four ways: a
list of dicts, Hugging Face datasets, packmem share() and packmem open() of a saved table. It measures the
parent and every worker.
pip install torch datasets psutil huggingface_hub packmem
python run.py --mode list
python run.py --mode packmem-openShows: one changed line in a training loader, and how much memory each worker holds under fork and spawn.
Edit this page · Every page as Markdown for agents: llms-full.txt