From 9879bdf4daba2b336c26afcb97a07a4d016dde42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Tejero=20Cantero?= Date: Fri, 17 Jul 2026 00:25:02 +0200 Subject: [PATCH] :sparkles: Report actual graph memory from the buffer manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- backend/resources/app/templates/graph-console.tmpl | 6 +++++- backend/src/app/graph/debug.clj | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/resources/app/templates/graph-console.tmpl b/backend/resources/app/templates/graph-console.tmpl index 2ae62a741f..1a56c12181 100644 --- a/backend/resources/app/templates/graph-console.tmpl +++ b/backend/resources/app/templates/graph-console.tmpl @@ -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; diff --git a/backend/src/app/graph/debug.clj b/backend/src/app/graph/debug.clj index 69144db317..256f183006 100644 --- a/backend/src/app/graph/debug.clj +++ b/backend/src/app/graph/debug.clj @@ -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}))))