Skip to content

fix(lang): per-source copy attribution in MemoryTracker; volatile ActiveMemoryTracker (#931) - #938

Merged
michalharakal merged 6 commits into
developfrom
fix/memorytracker-source-attribution-931
Aug 10, 2026
Merged

michalharakal merged 6 commits into
developfrom
fix/memorytracker-source-attribution-931

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Full analysis in #931.

  • recordCopy stops discarding its label: aggregate reports gain copiesBySource: Map<String, CopySourceStat> (count + bytes per code path), rendered in the text report sorted by volume, reset by clear(). Profiling sessions can finally see which path produced the copy traffic — the attribution the API always appeared to offer.
  • ActiveMemoryTracker.current is @Volatile with 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.

AggregateMemoryReport gains the new field with a default value — source-compatible for any external constructors.

Verified: :skainet-lang:skainet-lang-core:jvmTest green (full module).

Note: CHANGELOG entry included — trivial [Unreleased] conflicts expected with the sibling #927–#930 PRs.

Closes #931

…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
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-938 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal
michalharakal requested a review from aharakal August 10, 2026 08:59
aharakal
aharakal previously approved these changes Aug 10, 2026
Resolve the [Unreleased] CHANGELOG conflict with the merged #930 entry:
keep all bullets.
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-938 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-938 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-938 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal
michalharakal requested a review from aharakal August 10, 2026 13:12
@michalharakal
michalharakal merged commit 9261ff8 into develop Aug 10, 2026
11 of 12 checks passed
@michalharakal
michalharakal deleted the fix/memorytracker-source-attribution-931 branch August 10, 2026 13:14
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-938 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory diagnostics: MemoryTracker.recordCopy discards the source label every caller passes; ActiveMemoryTracker is a mutable global

2 participants