fix(lang): per-source copy attribution in MemoryTracker; volatile ActiveMemoryTracker (#931) - #938
Conversation
…iveMemoryTracker MemoryTracker.recordCopy(sourceName, bytes) discarded sourceName — it only bumped copyCount/copyBytes, while every instrumented call site passes a meaningful label (CopyMaterializationStrategy, DenseTensorDataFactory.createFloatTensorData, ...). The API promised per-source attribution and threw it away. Aggregate reports now carry copiesBySource: Map<String, CopySourceStat> (count + bytes per code path), included in the report's text form sorted by volume, and reset by clear(). ActiveMemoryTracker.current becomes @volatile so installing/clearing a tracker is visible across threads, and its doc now states the honest contract: the tracker itself is not synchronized, concurrent sessions should install their own around their critical section. Replacing the process-wide hook with a per-execution-context tracker is part of the SKEEP-003 storage-model discussion (#932) and intentionally out of scope here. Tests: per-source aggregation across repeated and distinct sources, clear() resetting attribution, and the text report containing the breakdown. Closes #931
|
📖 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. |
Resolve the [Unreleased] CHANGELOG conflict with the merged #930 entry: keep all bullets.
|
📖 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. |
|
📖 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. |
|
📖 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. |
|
📖 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. |
Full analysis in #931.
recordCopystops discarding its label: aggregate reports gaincopiesBySource: Map<String, CopySourceStat>(count + bytes per code path), rendered in the text report sorted by volume, reset byclear(). Profiling sessions can finally see which path produced the copy traffic — the attribution the API always appeared to offer.ActiveMemoryTracker.currentis@Volatilewith an honest thread-safety contract in the docs (tracker itself unsynchronized; concurrent sessions install their own). Replacing the process-wide hook with a per-execution-context tracker is deliberately left to the SKEEP-003 storage-model discussion (TensorData and TensorStorage are parallel layers — unify the storage model (ownership, views, dtype/encoding, placement): SKEEP-003 discussion anchor #932) — noted in the docs so the limitation is discoverable.AggregateMemoryReportgains the new field with a default value — source-compatible for any external constructors.Verified:
:skainet-lang:skainet-lang-core:jvmTestgreen (full module).Note: CHANGELOG entry included — trivial
[Unreleased]conflicts expected with the sibling #927–#930 PRs.Closes #931