GUI, CLI, and benchmarks · Engineering

RAM footprint: what is and is not in RSS

Idle memory, page cache, virtual size, peak scans, and the 26 MiB process number next to a 206M-row dataset.

Memory numbers are the easiest benchmark claim to misread. A process RSS of 26 MiB next to a 206M-row dataset sounds impossible until you separate process memory from the OS page cache.

NonoDB’s published numbers make that separation explicit. The database is memory-mapped, so the kernel can cache pages outside the process. That is not a trick, but it is not the same as “the whole dataset fits in 26 MiB”.

The verified numbers

  • ~5 MB idle RSS with 1M documents and three indexes;
  • ~26 MiB process RSS in the 206M-row benchmark, with OS page cache excluded;
  • virtual size can be much larger because it includes the map_size reservation.

In the 206M benchmark, TimescaleDB’s cgroup memory was about 2.2 GiB, mostly file/shmem, with a per-query work_mem budget of 128 MB. NonoDB’s process stayed around 26 MiB because it does not allocate a per-query buffer of that size.

The comparison is not apples to apples: NonoDB’s RSS excludes page cache, while a cgroup includes file/shmem. The benchmark documents that caveat.

RSS versus PSS versus virtual size

  • RSS — resident set size, pages mapped into the process and currently resident.
  • PSS — proportional set size, splits shared pages across processes.
  • Virtual size — address space, including the LMDB map reservation.

A 1 GiB map does not allocate 1 GiB of RAM. The file grows as data is written, and RSS grows with pages actually touched. A large virtual size is not a leak.

Representative measurements on the benchmark host:

State RSS PSS
1,000 documents, 3 indexes, idle ~5.1–5.4 MB ~2.6–3.0 MB
1M documents, 3 indexes, idle after restart ~5.1 MB ~2.9 MB
1M documents, after a few reads ~6.4 MB ~4.0 MB
1M documents, after a full scan + sort ~278 MB ~276 MB
1M documents, peak during parallel index backfill ~552 MB —
100k text/fuzzy documents up to ~788 MB peak —

The large numbers are mostly mapped pages and page cache, not Rust heap.

Why idle memory is small

The idle process holds:

  • the Tokio runtime and request handling;
  • the LMDB environment handle;
  • configured caches;
  • small metadata structures.

The documents and indexes live in the mapped file. Reading a page brings it into the page cache; the process does not copy the whole database into a heap.

That is why a restart drops process RSS to a few MB. The OS may keep pages cached, so a system-wide memory view will still show them.

Why peaks are larger

A full scan touches many pages. A sort may materialize results. An index backfill can use multiple workers and bounded queues. Text/fuzzy index builds can use substantial memory.

The peak is workload-dependent, not a fixed database overhead:

  • nonodb full scan + sort on 1M documents: ~278 MB;
  • parallel index backfill peak: ~552 MB;
  • 100k text/fuzzy build: up to ~788 MB.

On a 1 GB VM, those peaks matter. The idle number does not tell you whether a large index build will fit.

Page cache is not free

Excluding page cache from process RSS is fair for measuring process overhead, but it is not a claim that the data needs no RAM. If the working set fits in page cache, reads are fast. If it does not, reads go to disk.

The 1B benchmark shows this:

  • _id lookups stayed under 1.5 ms p99;
  • a full scan over 46 GB took 625.6 s because the data did not fit in RAM.

The lookup is indexed and touches few pages. The scan reads the dataset. Both are honest.

Caches and knobs

  • NONODB_CACHE_TTL controls the shared read cache (default 5 seconds).
  • NONODB_CACHE_ENTRIES and NONODB_CACHE_MAX_BYTES bound it.
  • NONODB_AGGREGATE_MAX_DOCS bounds aggregation input.
  • Small profiles reduce threads, open databases, cache entries, scan workers, and TTL batch sizes.
  • NONODB_MAP_SIZE is an address-space reservation, not a RAM allocation.

Disabling the cache lowers memory but can increase repeated-read cost. On a constrained host, measure both.

What the 26 MiB claim does not mean

It does not mean:

  • the 206M rows fit in 26 MiB of RAM;
  • page cache is unnecessary;
  • every query uses 26 MiB;
  • an index build fits in 26 MiB;
  • RSS is the only memory cost in a container.

It does mean the daemon’s own process overhead stayed around 26 MiB during that benchmark, while the kernel cached file pages separately.

How to size a host

  1. Measure idle RSS after restart.
  2. Add the peak for your largest scan, sort, index build, or text build.
  3. Add page cache for the hot working set, as far as the host allows.
  4. Leave headroom for the OS, Docker, and other services.
  5. Watch the OOM killer and swap, not just RSS.

On a 1 GB VM, a small indexed workload can be comfortable while a large text index build is not. That is not a contradiction; it is the difference between idle overhead and peak work.

The operations guide and benchmark page document the measurements and caveats.

All engineering notes →Read the docs