Repository navigation
Conversation
The opt-in runtime memory profiler (FLOW_MEM_PROFILE) now attributes allocations to their source sites, counts stack and arena promotion bytes, keeps a live-block map with an overflow counter, and the MLIR backend routes allocations through the same hooks. It is runtime accounting; #669 static lifetime analysis is separate. docs/library/memory-profile.md documents the report keys. Rebased from PR #1366 onto current main. Conflicts kept main's lazy profiler init (#746) and memory-suite-only harness profiling, with this PR's new counters.
b863d83 to
d0582be
Compare
|
Rebased onto main Rebase: conflicts kept main's lazy profiler init (#746) and memory-suite-only harness profiling with this PR's new counters (cgen comment, memory.md, CHANGELOG). What passes on the rebased tree: flowc selftest; What fails, and it is in this PR's MLIR hooks:
The roundtrip failure seen in the same run ( |
The opt-in runtime memory profiler (FLOW_MEM_PROFILE) now attributes allocations to their source sites, counts stack and arena promotion bytes, keeps a live-block map with an overflow counter, and the MLIR backend routes allocations through the same hooks. It is runtime accounting; #669 static lifetime analysis is separate. docs/library/memory-profile.md documents the report keys. Rebased from PR #1366 onto current main. Conflicts kept main's lazy profiler init (#746) and memory-suite-only harness profiling, with this PR's new counters. Fixed on rebase: the MLIR profiler registered flow_mem_report with atexit through llvm.mlir.addressof, which cannot name a func.func, so no MLIR program with the profiler lowered. It now takes the address with func.constant and an unrealized cast, as function values do elsewhere. The profiler prelude changes the emitted MLIR of programs that allocate, so the MLIR fixture goldens, the digests of the 748 affected corpus rows (no rows added), ten mlir_commands goldens and three CLI .files hashes (darwin and linux) are re-recorded.
Fixed point at gen2; bootstrap_from_c.sh --verify passes.
d0582be to
2800e6e
Compare
|
Update: fixed and ready (source
Gates: selftest PASS; Ordering: #1367 also changes the same three CLI hashes and cgen's profiler code. Whichever lands second has to re-run |
Intent
Part of #740 (parent #727). Related: #728. Does not overlap #669 / PR #1328 (static memory lifetimes).
Second slice of the opt-in runtime memory profiler after merged #1341. Adds the remaining runtime accounting: stack/arena promotion bytes, per-compiler-site copy/alloc attribution, a hashed capped live-block map with overflow, and MLIR-backend
flow_mem_*wrappers.Overlap check
Overlap / dependency notes: No open PR implements the remaining #740 profiler gaps. #1341 already landed the first heap/RSS/temp/copy slice. PR #1328 is the #669 static-lifetime MLIR
--lifetimesinput; this PR only counts stack/arena/compiler sites at runtime and does not change lifetime analysis.Evidence
Baseline before this change: generated C labelled stack/arena and per-site lines
(deferred, needs #669); live map was a 1024-slot linear scan with silent overflow; MLIR called@malloc/@memcpydirectly.Targeted proof that exercises the changed behaviour: see the testing commit / later Evidence update. Planned gates: host selftest,
tests/cgen/run.flow mem_profile,tests/scripts/mem_profile.flow, bootstrap--regen/--verifyin a follow-up commit.Why that proof would detect the old failure or regression: old flowc still emits the deferred #669 strings; missing stack notes fail
stack_bytes: 16; missing arena hooks failarena_bytes: 16; missing MLIR wrappers failfunc.call @flow_mem_malloc.Repository gate(s) run:
(pre-testing revision; gates follow)
Generated/bootstrap state, if any: bootstrap C not yet regenerated.
Risk
Compatibility, performance, security, lifetime, backend, or release implications:
Dormant unless
FLOW_MEM_PROFILEis set. Hashed 4096-slot map replaces the linear 1024 scan. One extra note call on sized-array locals and arena bumps. No language syntax change. #669 static lifetimes are untouched.docs/project/Questions.mdupdated if this needs a language-design decision.Compatibility
docs/project/CHANGELOG.md.Agent handoff
Pre-testing source commit. Bootstrap C regeneration is a separate commit after selftest.
Remaining gaps
Part of #740. Still open after this slice:
memcpytype-pun / record-update paths remain unrouted.