[wildfly-dev] Perf tip for folks writing management code
Darran Lofthouse
darran.lofthouse at jboss.com
Thu Sep 3 07:06:50 EDT 2015
On 26/08/15 20:19, Brian Stansberry wrote:
> 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);
For this line would it be better to use 'require'? It should not be
possible for it to be undefined but require would check that.
> ... 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. ;)
>
More information about the wildfly-dev
mailing list