grafeo icon indicating copy to clipboard operation
grafeo copied to clipboard

Enforce the memory limit, with honest accounting and a detected default

Open StevenBtw opened this issue 4 weeks ago • 0 comments

memory_limit is not enforced today: a store can grow far past it with no error (#398), the memory Grafeo reports is lower than what the process uses (#434), and the default budget ignores container limits and is fixed on Windows and macOS (#532). This feature makes the limit real, without a file format change.

What counts: everything the database holds: the graph store and its indexes, the RDF store, vector and text indexes, dictionaries and version history.

Behaviour

  • A write that needs memory past the limit fails with GRAFEO-S001, naming the memory used, the limit and how to raise it. The statement changes nothing; inside a transaction it is undone and the transaction stays usable.
  • Reads are never refused. Replaying the log at open is never refused.
  • A database already over the limit opens with a warning; reads work, writes that need memory fail until the limit is raised.
  • The default limit is 75% of the detected memory: cgroup v1/v2 on Linux, the system and job-object limit on Windows, the system memory on macOS.
  • The memory Grafeo reports matches what the process uses, within a measured and documented margin.
  • A per-query memory limit caps one statement's working memory (sorts, joins, aggregates), by default equal to the database limit; at the cap the statement spills to disk first and fails with GRAFEO-S001 only when it cannot.
  • The memory_usage() breakdown is exact per part and also reports the limit and the spilled bytes, in every binding.
  • The limits can be set from every binding: Python memory_limit and query_memory_limit, Node.js memoryLimit and queryMemoryLimit, and the C configuration for the bindings built on it.

Not yet (0.6.3, under #450): opening a database without loading all of it and evicting unchanged data under pressure (#713), what deleting data frees (#712), reclaiming deleted rows (#660), the memory benchmark (#431), a per-session query limit and changing the limit at runtime. Until then, deleting data does not lower the counted memory.

Done when the behaviour above holds in tests on all three operating systems, and common queries show no measurable cost.

Affected profiles: all

StevenBtw avatar Nov 07 '26 09:11 StevenBtw