Report actual graph memory from the buffer manager

graph-data gains bm-bytes (CALL bm_info() -> [mem_limit mem_usage], nil-safe, under the session lock); the session panel shows it as MiB behind the node/edge counts — real resident memory replacing the removed estimate.

Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>
This commit is contained in:
Álvaro Tejero Cantero 2026-07-17 00:25:02 +02:00
parent e011dedccf
commit 9879bdf4da
No known key found for this signature in database
2 changed files with 14 additions and 1 deletions

View File

@ -1074,8 +1074,12 @@ Graph Console
// shows per-table counts.
const sizeEl = document.getElementById("graph-size");
if (sizeEl) {
// bm-bytes = the session DB's buffer-manager usage (CALL
// bm_info()), i.e. actual resident memory, not an estimate.
const bm = data["bm-bytes"];
sizeEl.textContent = data.nodes.length + " nodes, "
+ data.edges.length + " edges";
+ data.edges.length + " edges"
+ (bm ? " (" + (bm / 1048576).toFixed(1) + " MiB)" : "");
const counts = {};
data.nodes.forEach(function (n) {
counts[n.table] = (counts[n.table] || 0) + 1;

View File

@ -255,6 +255,14 @@
(:rows inst))
:truncated? (boolean (or (:truncated? child) (:truncated? inst)))}))
(defn- bm-usage-bytes
"Buffer-manager memory in use by this session's in-memory database
(`CALL bm_info()` [mem_limit mem_usage]); nil if the call fails."
[conn]
(ex/ignoring
(-> (ladybug/query-on-connection! conn "CALL bm_info() RETURN *;" :max-rows 1)
:rows first second)))
(defn export-graph-data!
"Export the node/edge inventory of the in-memory graph for `profile-id`
as plain data for the debug graph view. Returns nil when no session is
@ -268,6 +276,7 @@
{:file-id (str file-id)
:revn (:revn index)
:truncated (boolean (or nodes-truncated? edges-truncated?))
:bm-bytes (bm-usage-bytes conn)
:nodes nodes
:edges edges}))))