Skip to content

Commit fce38ed

Browse files
committed
ArC: dependency graph improvements
- do not render the graph icon if no links exist - if a dependency graph exceeds the limit of 30 nodes then we apply the DevBeanInfos#MAX_DEPENDENCY_LEVEL and if still exceeds the limit it's skipped completely, i.e. dependency graph is not available
1 parent 3927812 commit fce38ed

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/devui/ArcDevModeApiProcessor.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import java.util.Set;
1111
import java.util.stream.Collectors;
1212

13+
import org.jboss.logging.Logger;
14+
1315
import io.quarkus.arc.deployment.ArcConfig;
1416
import io.quarkus.arc.deployment.CompletedApplicationClassPredicateBuildItem;
1517
import io.quarkus.arc.deployment.ValidationPhaseBuildItem;
@@ -29,6 +31,14 @@
2931

3032
public class ArcDevModeApiProcessor {
3133

34+
private static final Logger LOG = Logger.getLogger(ArcDevModeApiProcessor.class);
35+
36+
/**
37+
* If a dependency graph exceeds the limit then we apply the {@link DevBeanInfos#MAX_DEPENDENCY_LEVEL} and if still exceeds
38+
* the limit it's skipped completely, i.e. dependency graph is not available
39+
*/
40+
private static final int DEPENCENY_GRAPH_LIMIT = 30;
41+
3242
@BuildStep(onlyIf = IsDevelopment.class)
3343
public void collectBeanInfo(ArcConfig config, ValidationPhaseBuildItem validationPhaseBuildItem,
3444
CompletedApplicationClassPredicateBuildItem predicate,
@@ -85,6 +95,22 @@ public void collectBeanInfo(ArcConfig config, ValidationPhaseBuildItem validatio
8595
DependencyGraph dependencyGraph = buildDependencyGraph(bean, validationContext, resolver, beanInfos,
8696
allInjectionPoints, declaringToProducers,
8797
directDependents);
98+
if (dependencyGraph.links.isEmpty()) {
99+
// Skip the graph if no links exist
100+
continue;
101+
}
102+
if (dependencyGraph.nodes.size() > DEPENCENY_GRAPH_LIMIT) {
103+
DependencyGraph visibleGraph = dependencyGraph.forLevel(DevBeanInfos.DEFAULT_MAX_DEPENDENCY_LEVEL);
104+
if (visibleGraph.nodes.size() > DEPENCENY_GRAPH_LIMIT) {
105+
LOG.debugf("Skip dependency graph for %s - too many visible nodes: %s", bean,
106+
visibleGraph.nodes.size());
107+
continue;
108+
} else {
109+
LOG.debugf("Dependency graph for %s was reduced to visible nodes: %s", bean,
110+
dependencyGraph.nodes.size());
111+
dependencyGraph = visibleGraph;
112+
}
113+
}
88114
beanInfos.addDependencyGraph(bean.getIdentifier(), dependencyGraph);
89115
// id -> [dep1Id, dep2Id]
90116
beanDependenciesMap.put(bean.getIdentifier(),

extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/devui/DevBeanInfos.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public DevInterceptorInfo getInterceptor(String id) {
9090
}
9191

9292
public DependencyGraph getDependencyGraph(String beanId) {
93+
// Note that MAX_DEPENDENCY_LEVEL is not implemented in UI yet
9394
Integer maxLevel = DevConsoleManager.getGlobal(MAX_DEPENDENCY_LEVEL);
9495
if (maxLevel == null) {
9596
maxLevel = DEFAULT_MAX_DEPENDENCY_LEVEL;

0 commit comments

Comments
 (0)