Files
raea/tools/memprobe/holders.py
shinyobjectz b589826e7c RM1-RM10: halcyon r109's sequence from killed at 24-25 GB to a 7.8 GB peak (footprint 5.5 GB), the look within run-to-run noise
- RM1: materials' maps and Solari's traced meshes on the GPU only (RAEA_KEEP_CPU_ASSETS=1: the control)
- RM2: a sequence's first 3D engine let go before a second opens
- RM5: JS solids deduplicated by expression, their Manifolds in a two-generation cache (192 MB each); solid.free
- RM6: a map whose picture changes by frame is one part and one material, its picture swapped as frames show it
  (raea-sys-material swapped.rs): the pool's 96 water maps were 96 meshes and 186 textures
- RM7: Manifold shapes welded into indexed meshes (4.65 corners a vertex in halcyon; RAEA_NO_WELD=1: the control);
  a held frame settles to the same picture, boiling 0.30% against 0.38%
- the shape text kept out of the store and the Edit (the engine spawns from the program's rows)
- RM8: a BufferMesh of 64 KB or more kept on disk by its content (buffer:@NAME, raea's caches/buffers):
  shape text 274 MB -> 11.8 MB
- RM9: material maps as BC7 with their mips (intel_tex_2), cached by content in raea's caches/maps, any size
  resampled to whole blocks (RAEA_NO_BC=1: the control): GPU images 733 MB -> 282 MB
- RM10: raea-sys-contact's solids as bytes, a count and u16 surface points: 1.27 GB -> 0.37 GB mid-render
- memtally names the biggest GPU images; RAEA_MEM_MARKS prints the program's text by column and shape call
- tools/memprobe: memseq, heapwho/heapseq (malloc stack logging, holders.py), abenv/abseq/steadyab (A/B on one binary)

docs/render-memory.feature has each step's numbers and gates.
2026-11-29 16:02:31 -08:00

39 lines
1.7 KiB
Python

import sys, re, collections
# malloc_history -callTree: per line "<indent> COUNT (SIZE) FUNC (in LIB)". For each allocation leaf path we only have
# subtree totals; attribute each subtree to the deepest named raea frame whose own children are all non-raea (alloc libs).
size_re = re.compile(r'^([ +!:|]*)(\d+) \(([\d.]+)([KMGB]?)\) (.*?) \(in ([^)]*)\)')
mult = {'': 1, 'B': 1, 'K': 1e3, 'M': 1e6, 'G': 1e9}
def short(f):
ids = re.findall(r'\d+([A-Za-z_][A-Za-z0-9_]{2,})', f)
ids = [i for i in ids if not re.match(r'^(Cs|Nt|Nv|Ns|Ny|NC|Ms|Ib|IN|B[0-9])', i)]
return '::'.join(ids[-3:]) if ids else f[:80]
nodes = [] # (depth, bytes, func, lib)
for line in open(sys.argv[1], errors='replace'):
m = size_re.match(line)
if not m: continue
nodes.append((len(m.group(1)), float(m.group(3)) * mult[m.group(4)], m.group(5), m.group(6)))
# "self in raea" view: for each raea node, bytes minus bytes of raea children = allocated by it via non-raea callees
by = collections.Counter()
stack = []
for i, (d, b, f, lib) in enumerate(nodes):
while stack and stack[-1][0] >= d: stack.pop()
stack.append((d, b, f, lib))
# second pass: compute children sums of raea nodes
children = collections.defaultdict(float)
st = []
for i, (d, b, f, lib) in enumerate(nodes):
while st and nodes[st[-1]][0] >= d: st.pop()
if lib == 'raea':
# nearest raea ancestor
for j in reversed(st):
if nodes[j][3] == 'raea':
children[j] += b; break
st.append(i)
want = sys.argv[2] if len(sys.argv) > 2 else None
for i, (d, b, f, lib) in enumerate(nodes):
if lib == 'raea':
own = b - children[i]
if own > 0: by[short(f)] += own
for f, b in by.most_common(40):
print(f"{b/1e6:8.0f} MB {f}")