RFR: 8309463: IGV: Dynamic graph layout algorithm [v12]
Roberto Castañeda Lozano
rcastanedalo at openjdk.org
Mon Aug 28 12:05:17 UTC 2023
On Mon, 28 Aug 2023 07:53:12 GMT, emmyyin <duke at openjdk.org> wrote:
>> ### Purpose
>>
>> IGV currently uses a static layout algorithm to visualize graphs. However, this is problematic due to the use cases of IGV. Most often, the graphs that are visualized are dynamic, meaning the graphs change over time. A dynamic graph can be thought of as a sequence of graphs where a given graph in the sequence is the state of the dynamic graph at that point in time. Static layout algorithms do not account for the rest of the sequence when visualizing a given graph. On one hand, it makes each layout more readable. But on the other hand, the layout for two consecutive graphs in the sequence can be vastly different even though the difference between the graphs is small. This makes it difficult to identify the changes that has occurred to the graph and can damage the internal understanding of the graph that the viewer has obtained. A dynamic layout algorithm takes the changes into account when visualizing a graph. To enhance IGV, such an algorithm has been implemented in this PR.
>>
>> The layout drawn by the static layout algorithm is called "sea of nodes", while the layout drawn by the dynamic algorithm is called "stable sea of nodes".
>>
>> The difference between the algorithms is illustrated in the following video:
>>
>>
>> https://github.com/openjdk/jdk/assets/52547536/35023362-a191-425e-b066-c7474db631f1
>>
>>
>> This work is the result of my Master's thesis which can be found [here](https://kth.diva-portal.org/smash/get/diva2:1770643/FULLTEXT01.pdf).
>>
>>
>> ### Implementation
>>
>> The algorithm is based on update actions that are applied incrementally to a graph layout in order to obtain the layout of the next graph in the sequence. By doing so, the nodes that appears in both graphs remain in their relative positions. A new layout manager called `HierarchicalStableLayoutManager` has been added which holds the core algorithm. The corresponding layout manager with the static layout algorithm is called `HierarchicalLayoutManager`.
>>
>> If no layouts have been drawn yet, the `HierarchicalLayoutManager` is used. This is because the dynamic algorithm needs an initial layout to apply the update actions on.
>>
>> The whole graph is represented by `LayoutNode` and `LayoutEdge` objects, that holds the positions of the nodes and edges along with other relevant information such as ID, name and size. These are updated, added and removed in accordance with the update actions.
>>
>> Since `HierarchicalStableLayoutManager` tries to preserve the node positi...
>
> emmyyin has updated the pull request incrementally with one additional commit since the last revision:
>
> only do sanityCheckEdges where necessary
As far as I understand, the only issue left to be addressed in this PR is the performance overhead caused by `sanityCheckEdges()`. I (together with @tobiasholenstein and @chhagedorn) suggest to replace it with a simpler method that only contains the logic strictly necessary for layout correctness, something like:
private void ensureNeighborEdgeConsistency() {
for (LayoutNode n : nodes) {
n.succs.removeIf(e -> !nodes.contains(e.to));
n.preds.removeIf(e -> !nodes.contains(e.from));
}
}
This does not entirely remove the overhead but at least mitigates it to an acceptable level.
While at it, could you remove the unused `sanityCheck...()` methods? Thanks!
-------------
Changes requested by rcastanedalo (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/14349#pullrequestreview-1598153971
More information about the hotspot-compiler-dev
mailing list