Skip to content

elfvis: deterministic treemap layout#1

Open
marciogranzotto wants to merge 1 commit into
mainfrom
fix/deterministic-treemap-sort
Open

elfvis: deterministic treemap layout#1
marciogranzotto wants to merge 1 commit into
mainfrom
fix/deterministic-treemap-sort

Conversation

@marciogranzotto

@marciogranzotto marciogranzotto commented Mar 5, 2026

Copy link
Copy Markdown

User-Facing Release Note

Treemap visualization is now fully deterministic — running elfvis multiple times on the same ELF file always produces the same layout.

What Changed (Technical)

In src/tree.rs, the children sort (finalize_sizes) now uses name as a secondary key when sizes are equal: b.size.cmp(&a.size).then_with(|| a.name.cmp(&b.name)). This makes the sort fully deterministic regardless of HashMap iteration order.

What Needs Testing

  • Run elfvis on the same ELF file multiple times and verify identical SVG output
  • Verify existing tests still pass (43/43 passing)

Known Issues and Limitations

None.

Security Analysis

No security-sensitive changes.

HashMap iteration order in cluster_unknown_children is randomized,
so clusters with equal total size could appear in different order
across runs. Add name as a secondary sort key to guarantee a stable,
reproducible layout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@marciogranzotto marciogranzotto marked this pull request as ready for review March 5, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes treemap layout deterministic by ensuring child nodes are sorted with a stable, total ordering when sizes are equal.

Changes:

  • Adds a secondary sort key (name) when child sizes compare equal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants