[wildfly-dev] Perf tip for folks writing management code

Brian Stansberry brian.stansberry at redhat.com
Wed Aug 26 15:19:04 EDT 2015


If you're writing code that manipulates potentially large chunks of the 
management model, be cautious of the following:

1) org.jboss.as.controller.Registry.Tools.readModel(final Resource resource)

This makes a deep clone of all the DMR model nodes in the given resource 
tree. That may be a good thing, but is expensive with large trees, so be 
aware.

2) org.jboss.dmr.ModelNode.asPropertyList()

For each Property in the returned list, the 'value' member is a deep 
clone of the corresponding element in the original model node. So, again 
expensive with large trees, so be aware.

You can replace this:

for (Property prop : node.asPropertyList() {
    String name = prop.getName();
    ModelNode value = prop.getValue();
    ... do something with name and value
}

with

for (String name : node.keys()) {
     ModelNode value = node.get(name);
     ... do something with name and value
}

I'll fix a few high impact cases of this usage.

Please resist the urge to send in lots of refactoring PRs until WF 10 is 
done. ;)

-- 
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat


More information about the wildfly-dev mailing list