---
title: "Store a 1 MB document in memory, and time it on your machine"
slug: a-megabyte-document-into-memory
date: 2026-10-28
author: Semurg
section: how-to
tags: [memory, documents, performance, how-to]
summary: A short program that stores about 1 MB of text in a node's memory and asks a question of it. On our test machine the document stores in about 1.8 seconds; the program prints your own time.
status: published
constants: [1, 200, 20, 16, 8, 2026, 27]
evidence:
  - release:r11.132.20261027.a274a28
covers: [route:POST /v1/memory/document, route:POST /v1/memory/remember, route:POST /v1/memory/context, sdk:document, sdk:remember, sdk:context]
---
> Last checked on r11.134.20261027.a9b1536 (27 Oct 2026): every command below ran on a fresh node of that release. The current release is r11.135.20261028.2ff2348 (28 Oct 2026), and the commands have not been re-checked on it yet.

A 1 MB text document stores in about 1.8 seconds on our test machine (1.8 s, 1.7 s and 1.8 s over three runs, on the release
published on 27 October 2026).[^1] We measured it on one machine, 16 cores with the node in a container limited to 8 GB of
memory, with the meeting notes the program below writes. The program prints your own time.

## Time it yourself

You need a running node ([install one](/install); the installer prints the node's API token, and on the Docker route it is in the
container's log) and the Python client in its own environment, with the token set in the same shell:

```bash
python3 -m venv ~/semurg-venv && . ~/semurg-venv/bin/activate
pip install semurg
export SEMURG_API_TOKEN=<your token>
```

The program first tells the memory about 200 people and 20 companies, so the document has names to recognise, then stores about
1 MB of meeting notes that mention them, and asks one question of what it stored. Save it to a file and run it with `python3`.

```python runnable kind=sdk:python needs=token
import os, time
from semurg import Client

c = Client("http://127.0.0.1:4000", token=os.environ["SEMURG_API_TOKEN"])
scope = "meeting-notes"

first = ["Ada", "Grace", "Alan", "Edsger", "Barbara", "Donald", "Margaret", "Ken", "Dennis", "Frances",
         "John", "Radia", "Leslie", "Tony", "Shafi", "Niklaus", "Hedy", "Claude", "Katherine", "Tim"]
last = ["Lovelace", "Hopper", "Turing", "Dijkstra", "Liskov", "Knuth", "Hamilton", "Thompson", "Ritchie", "Allen"]
people = [f"{f} {l}" for f in first for l in last]
companies = [f"{n} Holdings" for n in ["Acme", "Globex", "Initech", "Umbrella", "Stark", "Wayne", "Tyrell", "Cyberdyne",
                                        "Soylent", "Hooli", "Vandelay", "Wonka", "Gringotts", "Monarch", "Oscorp", "Pied Piper",
                                        "Aperture", "Black Mesa", "Massive Dynamic", "Wernham Hogg"]]

# 200 people and 20 companies the memory already knows
c.remember(scope, facts={
    "entities": [{"name": p, "type": "Person"} for p in people] + [{"name": k, "type": "Company"} for k in companies],
    "relations": [{"source": p, "target": companies[i % 20], "type": "WORKS_AT"} for i, p in enumerate(people)],
})

# about 1 MB of meeting notes that mention them
lines, size, i = [], 0, 0
while size < 1_000_000:
    a, b, k = people[i % 200], people[(i * 7 + 3) % 200], companies[(i * 3) % 20]
    line = f"Meeting {i}: {a} and {b} reviewed the {k} contract, agreed the delivery date and asked finance for revised figures."
    lines.append(line)
    size += len(line) + 1
    i += 1
doc = "\n".join(lines)

t0 = time.perf_counter()
c.document(scope, doc, name="meeting-notes.txt")
print(f"stored {len(doc.encode()) / 1e6:.2f} MB in {time.perf_counter() - t0:.2f} s")

answer = c.context(scope, "Who reviewed the Acme Holdings contract?", compact=True)
print(f"answer: {answer.get('state')}, {answer.get('grounding', {}).get('state')}, {len(answer.get('items', []))} items")
```

```expect
expect: the document is stored and the question is answered from it
assert: out~^stored 1.00 MB in ;out~^answer: answered, grounded
```

The first line is your time. The second says the question was answered from what you stored: `grounded` means the cited items
cover the question.

*This post was written with AI assistance. Every result in it is checked against a published release or record before the post goes out.*
