`op=callgraph_refresh` reaches ~20 GB on 0.64.0 at 4.6 GB callgraph-store scale — the #330 unbounded materialization is still unbounded at 4× the validated store size
Short description
Every daemon spawn on 0.64.0 schedules a full callgraph_refresh that reaches ~20 GB RSS in ~12 minutes against a 4.6 GB callgraph store (~4× the scale #330 was closed on) and is host-OOM-killed; the cold respawn re-runs the identical build and re-balloons. This is the re-measure #330's closing comment invited.
What happened?
Backstory in one line: #330 was closed as fixed in 0.57.2 on our validation runs (3.4 GB scarred store, dead-code pass peak 2.63 GB), with the door left open — "If the bounded-materialization work goes ahead, we'll ask you to re-measure on the same store." This is that re-measure, on a larger store, and it fails.
Environment. AFT daemon inside a Linux docker container (no memory/CPU limits; host 30 GB + swap, shared with other containers). Plugin and binary both 0.64.0, resolved fresh at container start (Nov 13, 2026). Project: a private Java monorepo, 138,578 files / 9.6 GB working tree (38,502 files walked at configure; 97,925 dependencies in the LSP applicability walk); mostly Java, no Java LSP. Index store accumulated since August: callgraph corpus 4.6 GB on disk (~4× the 3.4 GB store #330 was validated on), 10.25 GB total. Config: indexes: { trigram: true, semantic: true, callgraph: true } — all planes on; the former #330 workaround (callgraph_store: false) was lifted after 0.57.2, and this store has been building with callgraph on since August. Semantic capped at max_files: 50000; the semantic plane is verifiably NOT involved (daemon reuses the old vector index: semantic.bin: 37,708 files, 380,088 rows read in 5318 ms, then quiet).
The loop, 2026-11-13 (daemon log files aft-512.log, aft-2996.log, aft-3836.log, aft-7774.log — one per daemon lifetime):
- 11:35 daemon spawns after sandbox restart; ~12 min later the kernel OOM-kills it:
Out of memory: Killed process 38103 (aft) anon-rss: 19.9GB, memcg = the agent container. - 11:48 respawn → killed 11:59:29, anon-rss 21.8 GB.
- 12:00 respawn → killed 12:12:08, anon-rss 21.1 GB. Its final log line, 26 s before the kill:
allocator slack relief: rss_bytes_before=Some(19887885024). - 12:12:24 respawn (4th) — same trajectory again (0.9 → 3.1 GB by minute 6, ~0.5–1 GB/min).
The daemon names the operation itself, via the 0.64 memory logging:
WARN allocation burst: op=callgraph_refresh live 512 MiB crossed 512 MiB
thread=aft-resolve-7 root=workspace build_id=365D6592F6FB1C32A105E76CAC35547BE75EC3B8 frames=...
WARN large allocation 73 MiB alloc thread=aft-resolve-0 op=callgraph_refresh root=workspace
build_id=365D6592F6FB1C32A105E76CAC35547BE75EC3B8
INFO allocator slack relief: ... rss_bytes_before=Some(16683802616) # daemon 2, minute ~11
The same build_id=365D6592… recurs across all four daemons: each spawn re-runs the same full refresh from zero.
Why every respawn re-balloons (the #330 loop, unchanged). Each daemon dies mid-build, before any phase checkpoint — the store is verifiably untouched across all three kills (no file under the store has an mtime inside the container's lifetime). The respawned cold daemon therefore cannot take any incremental path and re-runs the FULL materialization. SIGKILL → cold FULL → balloon → SIGKILL. A store reset would buy exactly one cycle, per #330's own analysis; we have not done one.
Two details that narrow where the bytes go.
- The ballooning threads are
aft-resolve-*underop=callgraph_refresh, and the store's callgraph corpus has been stale since Aug 24 (last complete build). So this is the resolve/materialization side of a full refresh against a large stale corpus, not the dead-code projection of 0.57 — but it exhibits the identical unbounded-growth shape at ~4× the validated store scale. Whether it is the sameproject_snapshotFULL arm carried into the 0.64 one-store engine or a new equivalent, the #330 property ("peak scales with store size; a killed process can never inherit the cheap path") still holds on 0.64.0. - 0.64.0's published memory claims (peak 1.5–2.4 GB) are measured on AFT's own ~7,300-file repository. We see no evidence the refresh path was ever measured against a multi-GB store.
Side effects beyond aft. The container has no memory limit, so each cycle drives the 30 GB host into reclaim and ~7 GB of swap before the global OOM killer fires; three other agent containers on the host carry older exit-137 records from previous days, though today's kernel log attributes every kill to aft.
Diagnostics
- Repro: 2026-11-13, linux x64 docker container, no cgroup memory limit (global OOM,
CONSTRAINT_NONE), host 30 GB + swap
- Plugin: @cortexkit/aft-opencode 0.64.0; AFT binary 0.64.0 (both verified from the
container's resolved npm cache at runtime, not assumed)
- Project: a private Java monorepo, 138,578 files / 9.6 GB tree; 38,502 files walked at configure;
97,925 dependencies in LSP applicability walk; mostly Java, no Java LSP
- Store: callgraph corpus 4.6 GB (last complete build Aug 24), 10.25 GB total store,
accumulated since August
- Kill timeline 2026-11-13: 11:47:18 (anon-rss 19.9 GB), 11:59:29 (21.8 GB), 12:12:08
(21.1 GB); daemon 4 spawned 12:12:24, same op climbing when reporting
- Daemon self-reporting: `WARN allocation burst: op=callgraph_refresh` on aft-resolve-*
threads; `allocator slack relief` rss_bytes_before 16.7 / 21.5 / 19.9 GB per doomed daemon
- build_id=365D6592F6FB1C32A105E76CAC35547BE75EC3B8 identical across all daemon lifetimes
- Store mtimes: zero writes during the three doomed cycles (dies pre-checkpoint)
- Semantic plane excluded: `reusing vectors of the old meaning index semantic.bin:
37,708 files, 380,088 rows, read in 5318 ms`, then quiet; max_files 50000
- Full per-daemon logs preserved: aft-512/2996/3836/7774.log (one per lifetime)
Plugin version
0.64.0
AFT binary version
0.64.0
Platform
linux x64 (daemon in a docker container; host 30 GB + swap, global OOM)
Log output (optional)
# Daemon 3 (aft-3836.log) — final 12 minutes of life; last line 26 s before the kill
2026-11-13T07:00:12.514Z WARN allocation burst: op=callgraph_refresh live 512 MiB crossed 512 MiB thread=aft-resolve-7 root=workspace build_id=365D6592F6FB1C32A105E76CAC35547BE75EC3B8 frames=aft+0x6365a0,...
2026-11-13T07:06:42.358Z INFO allocator slack relief: rss_drop_bytes=Some(2372771840) rss_bytes_before=Some(7521923072) rss_bytes_after=Some(5149151232)
2026-11-13T07:07:53.226Z WARN large allocation 73 MiB alloc thread=aft-resolve-0 op=callgraph_refresh root=workspace build_id=365D6592F6FB1C32A105E76CAC35547BE75EC3B8
2026-11-13T07:11:42.510Z INFO allocator slack relief: rss_bytes_before=Some(19887885024) rss_bytes_after=Some(19664265216)
# 07:12:08Z — kernel: Out of memory: Killed process 3836's host peer (aft) anon-rss: 21.1GB
# Daemon 4 (aft-7774.log) — same op, fresh cycle
2026-11-13T07:13:03.389Z WARN allocation burst: op=callgraph_refresh live 512 MiB crossed 512 MiB thread=aft-resolve-3 root=workspace build_id=365D6592F6FB1C32A105E76CAC35547BE75EC3B8
2026-11-13T07:17:28.111Z WARN allocation burst: op=callgraph_refresh live 512 MiB crossed 512 MiB thread=aft-resolve-0 root=workspace build_id=365D6592F6FB1C32A105E76CAC35547BE75EC3B8
2026-11-13T07:17:30.598Z INFO allocator slack relief: rss_drop_bytes=Some(998060032) rss_bytes_before=Some(4010274816) rss_bytes_after=Some(3012214784)
# Kernel (host journalctl -k), all three kills in the container's cgroup
# 11:47:18 — Killed process 38103 (aft) anon-rss: 19.9GB
# 11:59:29 — Killed process (aft) anon-rss: 21.8GB [host pid not captured]
# 12:12:08 — Killed process (aft) anon-rss: 21.1GB [host pid not captured]
# each: oom_memcg=docker-f7ee26d22e76... (the agent container)
Thanks for the detailed re-measure, and sorry about the loop. We're reproducing this now on a public Java repository of similar size, comparing 0.64.0 with our current development build, which includes call-graph memory reductions that aren't released yet.
To stop the loop until then, turn call-graph indexing off in your aft.jsonc:
{ "indexes": { "callgraph": false } }
Text and meaning search keep working; the call-graph tools report that the call graph is off. We'll post what we find here.
Here are relevant logs:
aft-plugin.log aft-21230.log aft-18849.log aft-16378.log aft-14722.log aft-7774.log aft-3836.log aft-2996.log aft-621.log aft-512.log
A smaller-scale data point for the call-graph memory work, from 0.64.0 on macOS (16 GB, Apple silicon). Different shape from the OOM loop above: nothing grows without bound and every burst is released, but the peaks are large for the repo size and they stack across processes.
Setup. One TypeScript monorepo, about 11,900 tracked files, opened by OpenCode in the main checkout plus short-lived git worktrees (one per agent task). Each worktree gets its own aft process. Default indexes config.
What the logs show. From the allocation burst ended: op=callgraph_refresh lines across the per-process logs since 0.64.0 started serving (Nov 12 to Nov 13), 21 bursts:
- Typical peak 1.2 to 2.5 GiB, lasting 5 to 130 s, each ending with
live 0.0 MiB now. - Largest: 5,171 MiB over 68.6 s, in a fresh worktree right after merging a large upstream release into it (about 2,100 files changed).
- Most bursts are in short-lived worktrees, so they cluster when several agent tasks run at once.
Overlap across processes. Because each checkout has its own process, the per-process refresh limit doesn't bound the machine total. Overlapping bursts from different PIDs (start = end − duration):
| Window (local) | Processes | Peaks |
|---|---|---|
| Nov 12, 15:19:42–15:20:51 | 3 (two worktrees + main checkout) | 1,361 + 2,318 + 2,205 MiB, about 5.9 GiB together |
| Nov 12, 17:53:17–17:54:12 | 2 (worktree + main checkout) | 1,186 + 2,368 MiB |
On a 16 GB machine running builds and tests at the same time, that is enough to push it into heavy swap.
What would help on our side: lower per-refresh peaks (the unreleased reductions mentioned above), or a machine-wide limit on concurrent call-graph refreshes across aft processes sharing the same store. Happy to re-measure on a pre-release build.
v0.66.0 rebuilds the first call-graph build around disk: output streams to disk, call resolution reads its inputs in bounded batches, and memory is returned between stages. On Linux in our tests, Elasticsearch now builds in 3.0 GiB instead of running out of memory, Chromium went from 30.9 GiB to 5.1 GiB, and VS Code from 17.9 GiB to 2.2 GiB. An interrupted build now resumes from its last finished stage. Could you try 0.66.0 on your project and tell us the peak you see? We're keeping this open while the largest projects are still above our 2 GiB target. Thanks for the detailed report, @OlegAndreych.
Re-measure on 0.66.0, as requested — the loop is gone and the first build completes, with one caveat about which path I measured.
Setup. Same private Java monorepo as the report (different branch): 39,429 files walked, 37,387 parsed, 3.18 GB of source. Fresh container, plugin and binary 0.66.0 (resolved from npm at container start), all indexes on, 30 GB host with ~10 GiB available during the build.
The first build, from the daemon log:
12:05:10 WARN allocation burst: op=index_build live 512 MiB crossed 512 MiB thread=aft-resolve-7
12:09:55 WARN allocation burst ended: op=index_build peak 10012 MiB over 284.9s, live 0.0 MiB now root=workspace
12:09:56 INFO data layer built /workspace: 39429 files, 37387 parsed, 3182375728 bytes; shared with other checkouts: 0 text units, 0 records, 0 fragments
12:10:09 INFO pre-warmed symbol cache from the data layer: 37387 loaded, 0 cached, 0 left, 13543 ms
- Peak 10,012 MiB over 285 s, then memory was returned between stages exactly as described — the daemon settled to 0.65 GiB resident idle a few minutes later and stayed there.
- The store was written (persisted under the one-store layout; the old pre-0.66
callgraph/directory is no longer written). - No OOM, no respawn loop — on 0.64.0 this same monorepo never completed a build: ~20 GB climb, host-OOM-killed three times, store untouched.
Caveat, to be precise about which path this exercises: this container has a fresh store volume, so what I measured is the first-full-build path (op=index_build), not the interrupted-refresh path (op=callgraph_refresh against the 4.6 GB store) that produced the original loop.
10 GiB is still above your 2 GiB target, consistent with keeping this open. Happy to run any follow-up you want at this repo size.
Follow-up: the interrupted-store refresh path, measured. The container holding the original report's store (the 4.6 GB callgraph corpus the loop died against) was recreated on 0.66.0 today. The first full build peaked 9,858 MiB over 165 s and completed (39,918 files / 37,856 parsed / 3.25 GB). Then op=callgraph_refresh — the exact operation from the report — ran twice against that store: peaks of 3,254 MiB over 31 s and 3,159 MiB over 14 s, each burst ending live 0.0 MiB now and publishing its changes, and the call-graph engine was released to idle (205 MiB) after 600 s without edits. The daemon now sits at 0.19 GiB resident. On this same store, 0.64.0 never completed a refresh: ~20 GB climbs, three host OOM kills, zero store writes.
Thank you for measuring both paths. That's exactly the evidence we needed.
To sum up your numbers on 0.66.0, for anyone following:
- First full build: completes on your 3.2 GB Java monorepo, peaking at about 10 GB for under 5 minutes, then idling at 0.2-0.65 GB. On 0.64.0 it never completed.
- Call-graph refresh against the original 4.6 GB store (the operation from your report): completes at about 3.2 GB. On 0.64.0 it never completed.
We're keeping this issue open because 10 GB is still well above our 2 GB target for a first build. The remaining pipeline work, streaming more build stages to disk, is aimed at that number. The next release also adds a memory: "lean" setting that trades some build speed for a lower peak. We'll ask you for one more run when the pipeline work lands.
One more refresh-path data point at this store scale. An interactive rebase (89 files changed) landed while a fresh daemon (new session, cold root snapshot) was starting. That combination — mass invalidation on a cold daemon — ran a full op=callgraph_refresh: peak 35,512 MiB over 547 s. It completed cleanly and returned the memory (~17 GiB released within 7 minutes of the burst ending, daemon settled at 1.3 GiB, no loop), but the peak was enough to briefly exhaust a 30 GiB host — one collateral kernel OOM kill of a shell child process. For contrast, incremental refreshes within a long-lived daemon on the same store peak around 3.2 GiB over ~30 s. So the full-materialization path at large-store scale is still the outlier versus the 2 GiB target.
Thanks, @OlegAndreych. The 35.5 GB run is the most useful data point so far. It matches something we measured this week.
When files change, AFT re-checks every call to each method name those files declare, across the whole repository. In Java, a changed class that declares methods like build, getId or equals pulls in every caller of those names. So an 89-file change can mean re-checking thousands of files. Today that refresh keeps all its work in memory, and it only switches to a full rebuild when a quarter of all files are queued. In our measurements, a refresh can grow to several times the memory of the full build it replaces. Your 35.5 GB is about 3.5 times your 10 GB first build.
We're fixing it in two steps:
- A refresh that grows past what the last full build used will stop and rebuild from disk instead. On your numbers, that is about 10 GB instead of 35. We plan it for the next release, along with changes that lower the first build on repositories with large files.
- After that, the refresh itself will work from disk, like the first build does now.
To make sure we tune this for repositories like yours, could you run the script below from the repository root and paste its output here? It reads the files git tracks, writes nothing, uses no network, and prints only counts and sizes: no paths, file names or code. With --show-names it also lists the 25 most-declared method names; share that part only if you're comfortable with it.
For reference, here is what it reports on two public Java repositories:
- Elasticsearch: 34,000 Java files averaging 9.9 KB. No method name is declared in 5,000 or more files. It runs in 9 seconds.
- Google's google-cloud-java: 135,000 Java files averaging 17 KB, 1.9 GB of them generated protobuf code. 27 method names (
build,newBuilder,mergeFrom,getDescriptorand so on) are each declared in 10,000 or more files. It runs in about a minute.
Your first build's log shows 3.25 GB across about 40,000 files, about 80 KB per file, so we'd like to know what makes up that size.
aft-repo-shape.py
#!/usr/bin/env python3
"""Summarize a repository's shape for AFT's call-graph memory work (issue #1441).
Read-only: it reads the files git tracks (or walks the folder if this is not a
git checkout), writes nothing, and uses no network. It prints counts and sizes
only: no file paths, no file contents. Method names are printed only with
--show-names, so the default output reveals nothing about your code beyond
sizes and counts. Review the output before you share it.
Usage, from the repository root:
python3 aft-repo-shape.py # aggregate numbers only
python3 aft-repo-shape.py --show-names # also the 25 most-declared method names
"""
import collections
import os
import re
import subprocess
import sys
GENERATED_MARKERS = re.compile(
rb"(@Generated|@javax\.annotation\.Generated|Generated by|DO NOT EDIT|"
rb"AUTO-GENERATED|Autogenerated|auto-generated|Code generated|protoc|"
rb"generated by the protocol buffer compiler)",
re.IGNORECASE,
)
# A Java or Kotlin method declaration: modifiers, a return type, a name, "(".
# Deliberately rough: these are aggregate counts, not a parse.
JAVA_METHOD = re.compile(
rb"^[ \t]*(?:@\w+(?:\([^)]*\))?[ \t]+)*"
rb"(?:(?:public|protected|private|static|final|synchronized|abstract|native|default|"
rb"override|open|suspend|inline|internal)[ \t]+)*"
rb"(?:<[^>\n]*>[ \t]+)?"
# The word before the name must be a type, not `new`, `return` or `throw`,
# or calls such as `throw new IllegalStateException(` would count.
rb"(?:fun[ \t]+|(?!(?:new|return|throw|else|case|yield|await)\b)\w[\w<>\[\],.? ]*[ \t]+)"
rb"(?<!\bnew )(?<!\breturn )(?<!\bthrow )(\w+)[ \t]*\(",
re.MULTILINE,
)
NOT_METHODS = {
b"if", b"for", b"while", b"switch", b"catch", b"return", b"new", b"throw",
b"else", b"synchronized", b"super", b"this", b"try", b"do",
}
SIZE_BUCKETS = [(10_000, "<10 KB"), (100_000, "10-100 KB"), (1_000_000, "100 KB-1 MB"),
(10_000_000, "1-10 MB"), (None, ">=10 MB")]
JAVA_LIKE = {".java", ".kt", ".kts", ".scala", ".groovy"}
def tracked_files():
try:
out = subprocess.run(["git", "ls-files", "-z"], capture_output=True, check=True).stdout
return [p.decode("utf-8", "surrogateescape") for p in out.split(b"\0") if p]
except (OSError, subprocess.CalledProcessError):
files = []
for root, dirs, names in os.walk("."):
dirs[:] = [d for d in dirs if d not in {".git", "node_modules", "target", "build"}]
files.extend(os.path.relpath(os.path.join(root, n)) for n in names)
return files
def bucket(size):
for limit, label in SIZE_BUCKETS:
if limit is None or size < limit:
return label
def gib(n):
return f"{n / 2**30:.2f} GiB" if n >= 2**30 else f"{n / 2**20:.1f} MiB"
def main():
show_names = "--show-names" in sys.argv
files = tracked_files()
by_ext = collections.defaultdict(lambda: [0, 0]) # ext -> [files, bytes]
by_bucket = collections.defaultdict(lambda: [0, 0])
generated = [0, 0]
java_generated = [0, 0]
top_level = collections.defaultdict(int)
declared_in = collections.Counter() # method name -> files declaring it
java_files = java_methods = 0
largest = []
for path in files:
try:
size = os.path.getsize(path)
except OSError:
continue
ext = os.path.splitext(path)[1].lower() or "(none)"
by_ext[ext][0] += 1
by_ext[ext][1] += size
by_bucket[bucket(size)][0] += 1
by_bucket[bucket(size)][1] += size
top_level[path.split("/", 1)[0] if "/" in path else "(root files)"] += size
largest.append(size)
if ext not in JAVA_LIKE and ext not in {".proto"}:
continue
try:
with open(path, "rb") as handle:
data = handle.read()
except OSError:
continue
is_generated = bool(GENERATED_MARKERS.search(data[:4096]))
if is_generated:
generated[0] += 1
generated[1] += size
if ext in JAVA_LIKE:
java_files += 1
if is_generated:
java_generated[0] += 1
java_generated[1] += size
names = {m for m in JAVA_METHOD.findall(data) if m not in NOT_METHODS}
java_methods += len(names)
declared_in.update(names)
total_bytes = sum(v[1] for v in by_ext.values())
print(f"tracked files: {len(files)} total size: {gib(total_bytes)}")
print("\nby extension (top 12 by size):")
for ext, (count, size) in sorted(by_ext.items(), key=lambda kv: -kv[1][1])[:12]:
print(f" {ext:10} {count:9} files {gib(size):>11} avg {size // max(count, 1):>9} B")
print("\nby file size:")
for _, label in SIZE_BUCKETS:
count, size = by_bucket.get(label, [0, 0])
print(f" {label:12} {count:9} files {gib(size):>11}")
largest.sort(reverse=True)
print("\n10 largest files (sizes only): " + ", ".join(gib(s) for s in largest[:10]))
print(f"\nfiles with a generated-code marker in their first 4 KB (Java/Kotlin/Scala/Groovy/proto): "
f"{generated[0]} files, {gib(generated[1])}")
print(f" of which Java/Kotlin/Scala/Groovy: {java_generated[0]} files, {gib(java_generated[1])}")
shares = sorted(top_level.values(), reverse=True)
print("\nshare of size in the 5 largest top-level folders (names not shown): "
+ ", ".join(f"{100 * s / max(total_bytes, 1):.1f}%" for s in shares[:5]))
print(f"\nJava-like files scanned: {java_files}, distinct method names per file summed: {java_methods}")
for floor in (100, 1_000, 5_000, 10_000):
names = [n for n, c in declared_in.items() if c >= floor]
print(f" method names declared in >= {floor:>6} files: {len(names):6} "
f"(those names cover {sum(declared_in[n] for n in names)} file declarations)")
if show_names:
print("\n25 most-declared method names (files declaring each):")
for name, count in declared_in.most_common(25):
print(f" {name.decode('utf-8', 'replace'):30} {count}")
if __name__ == "__main__":
main()
Two questions the script can't answer:
- Is generated code checked in (for example protobuf or gRPC classes, OpenAPI or JAXB clients, jOOQ), and roughly what share of the repository is it?
- In the 89-file rebase, were the changed files mostly hand-written classes or generated ones?
- Generated code is not checked in AFAIK.
- Mostly hand-written.
tracked files: 45467 total size: 501.3 MiB
by extension (top 12 by size):
.java 36276 files 189.0 MiB avg 5462 B
.png 967 files 57.3 MiB avg 62139 B
.traineddata 2 files 57.2 MiB avg 29994334 B
.xml 1019 files 40.4 MiB avg 41598 B
.dic 1 files 38.2 MiB avg 40017256 B
.zip 86 files 20.1 MiB avg 244999 B
.js 277 files 19.8 MiB avg 74883 B
.map 91 files 13.7 MiB avg 158342 B
.jar 48 files 9.6 MiB avg 210585 B
.properties 1067 files 5.5 MiB avg 5389 B
.groovy 1107 files 5.2 MiB avg 4915 B
.eml 44 files 4.9 MiB avg 117865 B
by file size:
<10 KB 39625 files 79.4 MiB
10-100 KB 5437 files 155.0 MiB
100 KB-1 MB 366 files 74.8 MiB
1-10 MB 34 files 71.3 MiB
>=10 MB 5 files 120.7 MiB
10 largest files (sizes only): 38.2 MiB, 30.4 MiB, 26.8 MiB, 15.2 MiB, 10.2 MiB, 5.8 MiB, 4.6 MiB, 4.0 MiB, 3.8 MiB, 3.4 MiB
files with a generated-code marker in their first 4 KB (Java/Kotlin/Scala/Groovy/proto): 269 files, 3.0 MiB
of which Java/Kotlin/Scala/Groovy: 269 files, 3.0 MiB
share of size in the 5 largest top-level folders (names not shown): 49.6%, 18.0%, 9.5%, 7.6%, 5.1%
Java-like files scanned: 37389, distinct method names per file summed: 197278
method names declared in >= 100 files: 97 (those names cover 27308 file declarations)
method names declared in >= 1000 files: 4 (those names cover 4735 file declarations)
method names declared in >= 5000 files: 0 (those names cover 0 file declarations)
method names declared in >= 10000 files: 0 (those names cover 0 file declarations)
25 most-declared method names (files declaring each):
prepareFixture 1309
init 1189
handleSuccess 1127
create 1110
onBind 784
execute 706
getTitle 663
toString 658
executeInTransaction 656
getCode 650
apply 644
setUp 607
get 571
getValue 540
getType 518
equals 462
configure 459
hashCode 448
getIconCode 424
refreshDisplay 410
validate 384
dispatch 334
getAssociatedType 331
isEnabled 328
doClone 312
Thank you, this is exactly what we needed, and it corrects a mistake of ours.
The 3.18 GB in your first build's log line (data layer built ... 3182375728 bytes) is the size of the index AFT wrote, not the size of your source. We misread it as source in our last comment. Your repository is ordinary: about 36,000 hand-written Java files averaging 5.5 KB, with no generated code to speak of.
That changes two of our conclusions:
- The 35 GB refresh still fits the cause we described, but through ordinary method names rather than generated ones. When a changed file declares a method, AFT re-checks every call to that name in the repository. Your top names are declared in 1,000+ files each (
prepareFixture,init,handleSuccess,create), so an 89-file rebase can queue thousands of files, and the refresh holds all of that in memory. The next release adds a guard: once a refresh grows past the memory of the last full build, it stops and runs the full build instead, which produces the same index. - The 10 GB first build is not explained by Java. A Java repository of similar size in our tests (Elasticsearch, 34,000 Java files) builds in about 3 GB. Something else is costing memory, and we have three leads.
Three more questions, if you're willing:
- How many CPU cores does the container see? The first build works on files in parallel, so its peak grows with the core count.
- Is meaning search on, and with which embedding backend (
semantic.backendin your AFT settings; it defaults to the localfastembedmodel)? Our 3 GB figure measures the text index and call graph only. - What are the extensions of the files over 1 MB, and are your
.jsand.mapfiles minified bundles? This command prints only sizes and extensions, no names:
git ls-files -z | xargs -0 stat -f '%z %N' 2>/dev/null | awk '$1 >= 1048576 { e = "(none)"; if (match($2, /\.[^.\/]*$/)) e = substr($2, RSTART); print $1, e }' | sort -rn
(On Linux, replace stat -f '%z %N' with stat -c '%s %n'.)
- 12
- "backend": "openai_compatible"
- They are, mostly
40017256 .dic
31873501 .traineddata
28115168 .traineddata
15410613 .xml
10660926 .zip
6074962 .js
4773966 .wav
4245554 .map
4027302 .png
3590529 .png
3050843 .zip
2912791 .xml
2793871 .map
2758821 .xml
2697241 .zip
2602363 .xml
2427278 .xml
2314603 .js
2272833 .png
2203906 .xml
2004930 .xml
1976306 .xml
1580033 .zip
1579500 .zip
1479807 .js
1453753 .map
1444992 .jar
1442770 .jar
1442752 .jar
1280003 .map
1228972 .xml
1228624 .xml
1213295 .eml
1143508 .htm
1139734 .docx
1117379 .js
1117379 .js
1088474 .jar
1081361 .mjs
Thanks for the numbers, and sorry for the slow follow-up.
What they tell us:
- The large files aren't the cause. AFT fully indexes files only up to 1 MB by default, and your files over 1 MB are mostly data (
.dic,.traineddata,.xml, archives, images). They add little to the build. - The embedding backend isn't the cause either. With
openai_compatible, AFT sends text to your endpoint and keeps only the vectors. Meaning search fills in small, bounded passes. - That leaves the call graph. Your repository declares common method names in 1,000+ files. AFT resolved such calls in fixed-size batches, so a batch from your repository held far more data than a typical one, and refreshes re-checked every caller of each name.
The next release, 0.67.0, carries three changes aimed at this:
- Call resolution batches are capped by size, not by file count. On a Linux kernel checkout this cut the first build's peak from about 4 GB to about 1.7 GB.
- A refresh that would use more memory than a full rebuild falls back to the full rebuild, which works from disk.
- Java calls on a type name (
Foo.bar()) resolve to that type when AFT can prove it, instead of matching everybarin the repository. On Spring Framework this removed about 16% of the name-only call links.
When 0.67.0 is out, could you measure again: the peak memory of the first build, and of a refresh after a rebase like the one you described? That will show how much of the 10 GB and 35 GB is left. A refresh that works from disk in bounded steps is in progress for what remains.
Refresh after a rebase on 0.67.1: both sides measured. AFT's own RSS and the kernel agree on about 1.8 GiB; AFT's allocation burst line reads about 10.8 GB. On 0.66.0 the same kind of rebase used roughly 35 GiB.
How. A throwaway container from the same image as my sandboxes (12 cores, all indexes on, default memory profile), a fresh clone of the same private Java monorepo (38,781 files walked), an empty store, and a 14 GiB memory cap with no swap that was never approached. I recorded what AFT reports in its own log (the allocation burst line and its periodic RSS lines) and what the kernel saw (the process's peak resident set, VmHWM; resident memory sampled once a second; the container's cgroup peak).
| Run | AFT: allocation burst peak |
AFT: own RSS (periodic lines) | Kernel: peak RSS | Time |
|---|---|---|---|---|
| First build on the empty store | op=index_build peak 10581 MiB |
0.74 GiB (at the start of the run) | 1.56 GiB | 214 s |
| Rebase moving 84 files (77 Java), daemon already running | op=index_build peak 10827 MiB |
1.48 GiB (90 s in) | 1.79 GiB | 317 s |
| Same rebase, then a fresh daemon started on the changed tree | op=index_build peak 10859 MiB |
1.27 GiB (40 s in) | 1.72 GiB | 279 s |
The whole container, file cache included, peaked at about 6 GB, and the host did not react. The last row is the situation from my 35 GB report: a rebase landing, then a cold daemon.
Two things in this table matter beyond the result.
-
The two AFT numbers are about six times apart on 0.67.1. The RSS lines agree with the kernel. The burst peak is far above anything the process held: its whole address space stayed under 6 GiB. My earlier "10 GB first build" numbers were the burst peak (10,012 MiB on 0.66.0; 9,927 and 9,928 MiB on 0.67.1), and I have no RSS figure for those runs. On 0.66.0 the 35 GB burst peak did match real memory, resident plus swap. What does the burst peak count, so that I label future numbers correctly?
-
A rebase-scale change now runs as a cold refresh, not as
callgraph_refresh. Both runs logdata layer cold refreshwithguard_fallback=false, so the new guard was not needed.
Limits of this measurement. One change size (84 files), a fresh clone of one development branch, 12 cores. During the first build an aft_inspect call also ran, so that row is an upper bound. I have not measured larger changes or the switch to a full rebuild.
Thank you for measuring both sides. That's the comparison we needed, and it settles the question for this change size.
What the allocation burst peak counts. It isn't resident memory. AFT's allocation tracer labels each operation (index_build, callgraph_refresh and so on). Rust heap allocations made on a thread while that label is set add to the label's count, and frees subtract only when they happen under the same label. Memory an operation hands to another thread, which later frees it there, stays on the count until no scope of that label is open any more. So the peak is an upper bound on what the operation held at once. A build that passes most of its data between threads, as the 0.67 build does, reads far above its real use. In the other direction, it never sees memory that C libraries (SQLite, tree-sitter, ONNX Runtime) take from malloc directly. For real memory, use the RSS lines or the kernel's figures, as you did. On 0.66.0 the two agreed because that build really held the memory.
Why the rebase ran as a cold refresh. Before an incremental call-graph refresh, AFT estimates how many files it would have to re-resolve. If that passes its limit, or no incremental engine is loaded (as on a freshly started daemon), it rebuilds through the same bounded path as a first build. That's what kept your rebase at 1.7–1.8 GiB. The text after the ; on the data layer cold refresh line names which limit applied.
Larger changes that stay on the incremental path are the case we're still working on: there, memory grows with how many call sites a change touches. If you later measure a bigger rebase or a branch switch, the kernel peak together with that log line would tell us which path it took.
The incremental path, measured for a ladder of change sizes. Same throwaway setup as above: 0.67.1, 12 cores, a 14 GiB cap that was never approached, no model calls. Each row is one commit applied by a rebase while the daemon was already running.
| Change | Path AFT took (from its own decision lines) | AFT: allocation burst peak |
Kernel: peak RSS | Burst time |
|---|---|---|---|---|
| First build on the empty store | — | op=index_build peak 10522 MiB |
1.37 GiB (VmHWM) |
166 s |
| 1 file | Incremental: call-graph refresh … guard_fallback=false … peak_growth_bytes=541716480 |
no burst line | 1.09 GiB | 1.5 s |
| 13 files | Incremental, then the guard: call-graph refresh exceeded its memory ceiling: growth=1429508096 ceiling=1423396864 sites=71937 files=92280; rebuilding cold, then a cold rebuild |
op=callgraph_refresh peak 1193 MiB over 3.5s, then op=index_build peak 10648 MiB |
2.17 GiB, at the second the guard fired | 268 s |
| 15 files | Estimate: invalidated=5017 threshold=3863 … crossed_at=method_readers, cold refresh |
op=index_build peak 10808 MiB |
1.82 GiB | 263 s |
| 48 files | Estimate: invalidated=11631 threshold=3865 … crossed_at=method_readers, cold refresh |
op=index_build peak 10849 MiB |
1.82 GiB | 250 s |
What this shows for this repository:
- The guard works here. The 13-file change stayed under the estimate's threshold, started on the incremental path, reached the ceiling in 3.5 s, and was handed to the cold rebuild. That ceiling, 1,423,396,864 bytes, is about the first build's real peak in the same daemon (1.37 GiB).
- Changes of 15 and 48 files never reach the incremental path. 15 changed files pull in 5,017 files and 48 pull in 11,631, against a threshold of about 3,865.
- No step went above 2.2 GiB. Mid-size and large changes now cost time: about four and a half minutes of rebuild, after a wait of about two minutes.
The kernel peaks after the first row are once-a-second samples, so the true peaks may be slightly higher. I did not measure a 7-file change, a branch switch, or changes larger than 84 files.
Thank you, this ladder is exactly what we needed, and it reads clearly.
What it tells us:
- Memory is now bounded on your repository. No step went above 2.2 GiB, and the refresh guard did its job on the 13-file change: it saw the refresh heading past the ceiling after 3.5 s and handed it to a cold rebuild.
- The cost has moved to time. Changes of 13, 15 and 48 files each end in a cold rebuild of about four and a half minutes, because the files they touch reach far into the call graph (5,017 and 11,631 files for the last two).
- The
allocation burstlines (10.5 to 10.8 GiB onindex_build) are far above the kernel's 1.4 to 1.8 GiB. That matches what we said before: the line counts allocations, not memory held, and it overstates a lot on a build like this.
The rebuild time is the next thing we're working on. A cold rebuild of this size shouldn't be the answer for a 13-file change. We'll post here when there's something you can measure.
If you get a chance, one more data point would help: a branch switch on the same repository, measured the same way.
A branch switch, measured the same way. Same throwaway setup: 0.67.1, 12 cores, no model calls, a 14 GiB memory cap with no swap. The container peaked at about 7 GiB, file cache included. The daemon had finished a first build on branch-A. I then switched with git checkout to branch-B, which differs from branch-A in 29,478 files, and back.
| Step | Path AFT took (from its own decision line) | AFT: allocation burst peak |
AFT: own RSS | Kernel: peak RSS | Time |
|---|---|---|---|---|---|
| First build on branch-A | — | op=index_build peak 10527 MiB |
0.93 GiB during the build | 1.38 GiB (VmHWM) |
254 s |
| Switch to branch-B (checkout 10 s) | changed=50955 threshold=3865 full=0 … crossed_at=changed, cold refresh |
op=index_build peak 9915 MiB |
1.05 GiB at the end of the rebuild | 2.04 GiB | rebuild 293 s; 6 min 14 s from checkout to done |
| Switch back to branch-A | changed=50955 threshold=3796 full=0 … crossed_at=changed, cold refresh |
op=index_build peak 10830 MiB |
1.89 GiB during the rebuild | 2.16 GiB | rebuild 350 s; 7 min 35 s from checkout to done |
What this shows:
- A full branch switch never reaches the incremental path. The changed-path count crosses the threshold at the first stage, so AFT goes straight to the bounded rebuild.
- Memory stays about 2 GiB, the same as for the rebase cases.
- The cost is time: six to eight minutes per switch, nearly all of it the rebuild. Afterwards the daemon is idle apart from periodic maintenance.
The kernel peaks for the two switches are once-a-second samples. During each switch the daemon also logged its language-server applicability walk stopping early, four times with RequestDeadline and once with RootUnreadable while files were being replaced. I did not measure a third branch.
Thanks, this is a clean measurement, and it matches what we see.
A switch that changes this many files is past the limit for an in-place refresh, so AFT rebuilds the call graph from scratch. Memory staying around 2 GiB is the bounded rebuild working as intended.
Almost all of the rebuild time is call resolution, not parsing. In our OpenJDK runs, re-reading files already in AFT's store takes about 25 s instead of about 65 s on a first build. Resolving calls takes about 340 s either way, and that part is not reused today. That's also why switching back to a branch AFT has already built costs as much as the first switch: the earlier branch's graph isn't kept for reuse.
A coming release logs how long each full build takes, and makes the allocation burst line say it's an upper bound on allocations. We're looking at whether a branch AFT has already built can reuse its earlier result. We'll post here once we know more.