Deduplicate rows in table reporter with identical displayed fields#892
Deduplicate rows in table reporter with identical displayed fields#892abhiojha8 wants to merge 1 commit into
Conversation
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>
ced7199 to
67ae8db
Compare
|
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
seeing a lint error: src/memray/reporters/table.py:39: error: Missing type arguments for generic type "tuple" [type-arg] |

Issue number of the reported bug or feature request: #857
Describe your changes
The table reporter creates one row per
AllocationRecordbut 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), summingsizeandn_allocations. No data is lost — the totals are preserved exactly.Additionally, this adds a
--split-threadsoption to thetablecommand, matching theflamegraphreporter's existing flag. By default threads are merged;--split-threadskeeps them separate.Closes: #857
Testing performed
exercise_3/lru_cache.pytutorial: 21 leaked allocation records that previously produced 21 rows (with 18 visual duplicates) now correctly produce 3 deduplicated rows with identical size/allocation totals