Skip to content

Latest commit

 

History

History
25 lines (13 loc) · 2.2 KB

design.md

File metadata and controls

25 lines (13 loc) · 2.2 KB

Threadscope design

Dump contains parsing, ownership analysis, cycle detection, and report generation. It does not depend on Swing. Main owns the UI and background loading. That separation allows the exact analysis used by the desktop to run in a terminal or a test.

Parsing

A recognized header starts a thread block. tid= is the preferred identity; headers without it receive a snapshot-local ID. A repeated ID rejects the input, which catches common accidental concatenations of multiple snapshots. The JVM's own deadlock appendix is not parsed as another set of threads.

The supported lock records are extracted from each block. Held monitors are collected first, then monitors released by Object.wait are removed. Unknown lines remain in the raw stack view even when they do not contribute to analysis.

Ownership graph

The first pass maps each monitor to observed owners. The second resolves waiting threads to owners only when exactly one owner exists. This conservatism avoids reporting a cycle based on contradictory ownership data.

Every thread has at most one outgoing wait edge in this model. Cycle detection walks those edges with a per-walk position map and a global completed set. Revisiting a node in the current walk identifies the cycle suffix. Reaching a completed path stops traversal. The algorithm is iterative, so long dependency chains do not exhaust the Java call stack.

Graph construction and cycle detection are O(V + E). The UI displays the resolved edges as a scrollable list of waiter-owner pairs; it avoids a force-directed layout whose movement could make incident comparison harder.

UI ownership

Swing widgets are accessed on the event-dispatch thread. File reading and parsing use a SwingWorker. Each load gets a monotonically increasing generation token. Completion only publishes its result if that token is still current, so a slow file does not overwrite a later demo or file selection.

Rendering and report export work from a completed snapshot. Search uses the raw block, preserving access to deeper frames that are not shown in the table.

Potential next steps are comparison across multiple timestamps and explicit ownable-synchronizer parsing. Neither is claimed by this version.