You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--emit neo4j holds the whole graph three times: 21–25 GB peak on nats-server and Kubernetes #38
--emit neo4j needs 3–5× the memory of the JSON output for the same graph. The JSON path streams the envelope module by module (v2emit.EmitTo); the Neo4j path materializes the whole graph three times before writing anything.
Measured on feat/l4-sdg at 98ebfef, go1.27.3, Apple M3 Max, -j 1 --eager:
app
-a 4 JSON: wall / peak RSS
--emit neo4j snapshot: wall / peak RSS
relationships
kubernetes (root)
38.4 s / 7.9 GB
99.7 s / 24.9 GB
8.29M
nats-server
23.8 s / 4.1 GB
118.3 s / 21.2 GB
9.61M
openbao
12.1 s / 5.8 GB
36.7 s / 13.7 GB
3.23M
k8s.io/api
10.6 s / 2.5 GB
29.5 s / 9.9 GB
2.85M
memos
5.1 s / 2.8 GB
13.1 s / 5.0 GB
1.19M
The snapshots are correct: every edge and body-node count equals the JSON's on all eight eval apps.
Cause
cmd/codeanalyzer/main.go → neo4j.EmitNeo4j:
v2emit.Emit builds the whole v2.Analysis tree (the JSON path uses EmitTo instead, one module at a time);
Project turns it into GraphRows, every node and relationship row at once;
RenderCypher renders the whole script to one string, which os.WriteFile writes (graph.cypher is 4.7 GB on nats-server).
So the tree, the rows and the script are all live together. WriteBolt avoids (3) but still holds (1) and (2).
Proposed fix
Stream like the JSON path: project and write one module at a time (types, callables, body nodes, flow edges), and the application-scope rows (call graph, param_in/param_out, stand-ins) last. Render Cypher batches straight to a buffered writer, and for Bolt send each module's batches as they are produced. The scoped wipe and the DDL stay at the head of the script.
Constraints to keep:
the output stays byte-identical to today's snapshot, so the existing golden and determinism tests gate it;
the cross-projection count gate (JSON and graph counts equal) still holds;
callEndpoint needs the set of declared ids for the whole application before the call-graph rows are written; that set is small (ids only) and can be collected in a first pass.
Why now
The python-sdk's Go backends are next. For large apps the Neo4j backend is the practical one (python-sdk loads JSON whole, and nats-server's analysis.json is 1.78 GB), so the emission should not need 3× the analysis memory.
Activity