Skip to content

Deduplicate rows in table reporter with identical displayed fields#892

Open
abhiojha8 wants to merge 1 commit into
bloomberg:mainfrom
abhiojha8:fix/table-reporter-dedup
Open

Deduplicate rows in table reporter with identical displayed fields#892
abhiojha8 wants to merge 1 commit into
bloomberg:mainfrom
abhiojha8:fix/table-reporter-dedup

Conversation

@abhiojha8
Copy link
Copy Markdown

Issue number of the reported bug or feature request: #857

Describe your changes

The table reporter creates one row per AllocationRecord but only displays the top stack frame (max_stacks=1). Records with different full call stacks that map to the same displayed top frame appeared as duplicate rows in the HTML table.

This change aggregates records in TableReporter.from_snapshot() by their displayed key (tid, allocator, top_frame), summing size and n_allocations. No data is lost — the totals are preserved exactly.

Additionally, this adds a --split-threads option to the table command, matching the flamegraph reporter's existing flag. By default threads are merged; --split-threads keeps them separate.

Closes: #857

Testing performed

  • All 630 tests pass (including 7 new unit tests and 1 updated integration test)
  • Verified on the exercise_3/lru_cache.py tutorial: 21 leaked allocation records that previously produced 21 rows (with 18 visual duplicates) now correctly produce 3 deduplicated rows with identical size/allocation totals
  • Pre-commit hooks all pass (ruff, black, isort, prettier, rstcheck, etc.)

@pablogsal
Copy link
Copy Markdown
Collaborator

Screenshot 2026-03-31 at 19 16 27 Something is very wrong here ....

The table reporter creates one row per AllocationRecord but only
displays the top stack frame. Records with different full call stacks
mapping to the same top frame appeared as duplicate rows.

Aggregate records sharing the same (tid, allocator, top_frame) key,
summing size and n_allocations. Also add --split-threads option to
the table command, matching the flamegraph reporter.

Signed-off-by: Abhi Ojha <abhiojha8@gmail.com>
@abhiojha8 abhiojha8 force-pushed the fix/table-reporter-dedup branch from ced7199 to 67ae8db Compare April 1, 2026 17:37
@abhiojha8
Copy link
Copy Markdown
Author

I force-pushed a cleaned version of this branch. The earlier oversized diff was caused by CRLF line endings in a few edited files, which made GitHub show large unrelated changes. The PR diff is now back to the intended 5-file patch for the table reporter fix and the focused table reporter tests pass on the updated commit.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.48%. Comparing base (87e7f62) to head (67ae8db).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #892      +/-   ##
==========================================
- Coverage   92.52%   92.48%   -0.05%     
==========================================
  Files          99       99              
  Lines       11726    11770      +44     
  Branches      426      426              
==========================================
+ Hits        10850    10885      +35     
- Misses        876      885       +9     
Flag Coverage Δ
cpp 92.48% <100.00%> (-0.05%) ⬇️
python_and_cython 92.48% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tvalentyn
Copy link
Copy Markdown

seeing a lint error:

src/memray/reporters/table.py:39: error: Missing type arguments for generic type "tuple" [type-arg]

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.

Duplicate entries in memray table --leaks reporter.

4 participants