Repository navigation
feat(memory): SKAINET_MEMORY_DEBUG — allocation-site tagging, use-after-close with the closing site, adapter log, leak reports (SKEEP-003 P2, S1.6) - #1075
Merged
Conversation
…er-close with the closing site, adapter log, leak reports (SKEEP-003 P2) Milestone M1 (#1002), PRD M1-F9, SKEEP-003 §4.7 / §8 item 4: the tool that would have found #782 in one run. - MemoryDebug: off by default (SKAINET_MEMORY_DEBUG=1 or -Dskainet.memory.debug=true; overrideEnabled for tests), costing one boolean read per allocation. On, it keeps a bounded ledger — storage id, scope, bytes, origin TensorId, allocation site, closing site — plus per-scope live and high-water bytes. - Breakpoint-like hooks (§4.7): onAllocate, onClose, onAdapter, onLeak. A debugger or a test breaks on "an allocation whose origin matches layers[3].*", "storage #412 closed", or "an adapter larger than X". - Storage records allocations and closes into the ledger and passes the call site into the trace event too; checkAlive()'s message now names where the storage was allocated and closed, which is the difference between "something is closed" and "this weight was freed at model.close(), you are reading it from the KV path". - platformCallSite(): a StackWalker frame outside sk.ainet.lang.memory on JVM/Android, null elsewhere; platformMemoryDebugEnabled() reads the env var and the property where there is one. - MemoryDebugTest: nothing recorded while off; allocations tagged with scope/origin/site; peaks survive frees; use-after-close names the tensor, scope and size; close hook fires once; adapter reporting; leak reporting distinguishes an escaped storage from a closed one; report() renders peaks and live storages. 97/97 memory tests. Closes #1026 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Local gate Targeted: |
|
📖 Documentation Preview The documentation has been built successfully for this PR. Generated Files:
Artifacts:
This comment will be updated automatically when the PR is updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SKEEP-003 slice S1.6 (milestone M1 #1002, PRD M1-F9, §4.7 / §8 item 4):
SKAINET_MEMORY_DEBUG— the tool that would have found #782 in one run.MemoryDebug: off by default (SKAINET_MEMORY_DEBUG=1or-Dskainet.memory.debug=true;overrideEnabledfor tests), costing one boolean read per allocation. On, it keeps a ledger — storage id, scope, bytes, originTensorId, allocation site and closing site — plus per-scope live bytes and high-water marks.onAllocate,onClose,onAdapter,onLeak. A debugger or a test breaks on "an allocation whose origin matcheslayers[3].*", "storage Bump actions/upload-pages-artifact from 3 to 4 #412 closed", "an adapter larger than 50 MB" — ordinary callbacks, no JVMTI.Storagewired in: allocations and closes are recorded (and the call site is passed into the trace event too), andcheckAlive()'s message now names where the storage was allocated and closed — the difference between "something is closed" and "this weight was freed atmodel.close(), you are reading it from the KV path".platformCallSite(): oneStackWalkerframe outsidesk.ainet.lang.memoryon JVM/Android,nullelsewhere;platformMemoryDebugEnabled()reads the env var and property where the platform has them.Evidence (
MemoryDebugTest, 97/97 memory tests): nothing is recorded while debug mode is off; allocations are tagged with scope/origin/site; peaks survive frees; use-after-close names the tensor, scope and size; the close hook fires exactly once; adapter reporting works; leak reporting distinguishes an escaped storage from a closed one;report()renders peaks and live storages.Test plan
Full local gate (
scripts/pr-gate.sh, JDK 25) — all legs passed; results in the first comment.Closes #1026
🤖 Generated with Claude Code