Confd 7.1 performance issue with JNC API

We are facing issue with confd 7.1, performance is slow for loading config data XML with >2.5 MB file. Below is the code snippet for RPC request with edit-config.

String topXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                    + "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">" + "<edit-config>" + "<target>" + "<running/>"
                    + "</target>" + 
                    "<default-operation>"+operationType+"</default-operation>\r\n" +
                    "<config>";
            String endXml = " </config>" + "</edit-config>" + "</rpc>";

            String rpc = topXml + snapshot + endXml;
            rpc = rpc.replaceAll("\\s*xmlns\\s*=\"\"", "");
            
            device = getDevice();
            if (device == null) {
                device = getDevice();
                closeDevice = true;
            }
            String reply;           
            NetconfSession netSession = device.getSession(confdIp + "_" + "RPC_SESSION");
            Element rpcData = netSession.rpc(rpc);
	    reply = rpcData.toXMLString();

               <dependency>
			<groupId>org.onosproject</groupId>
			<artifactId>jnc</artifactId>
			<version>1.0</version>
		</dependency>

We have enabled trace to the check the request time and resposne time:

<INFO> 23-Aug-2022::06:42:43.019  confd[58381]: netconf id=21 new ssh session for user "admin" from 127.0.0.1
<INFO> 23-Aug-2022::06:42:43.028  confd[58381]: netconf id=22 new ssh session for user "admin" from 127.0.0.1
<INFO> 23-Aug-2022::06:42:43.042  confd[58381]: netconf id=21 got rpc: {urn:ietf:params:xml:ns:netconf:base:1.0}edit-config attrs: message-id="1"
<INFO> **23-Aug-2022::06:42:54.536**  confd[58381]: netconf id=21 edit-config target=running attrs: message-id="1"
<INFO> **23-Aug-2022::06:45:04.592**  confd[58381]: netconf id=21 sending rpc-reply, attrs: message-id="1"
<INFO> 23-Aug-2022::06:45:04.615  confd[58381]: netconf id=21 ssh transport closed
<INFO> 23-Aug-2022::06:45:04.616  confd[58381]: netconf id=22 ssh transport closed

Please suggest how to improve the config XML load performance.

Could be many different things imho, that depends on the managed YANG modules.

Do you have some must or when statements used? Those, depending on structure can cause long processing time depending on big-O scale of the expressions.

Is there some external db or callpoints/transforms on the managed config nodes?
Same goes for validation callpoints that you might have etc.

@josephm Thanks for the reply.

We observed this issue in 7.1 confd version only after upgrading from 6.2.1 with no changes in client code.

Though as you mentioned, for testing i have removed fk refrences in config xml and found that “edit-config” took very less time. But this referenced data can’t be removed at live site.

Can you please suggest how can we improve performance at confd for this scenario.

Can you try your scenario with more recent ConfD version?
There have been some performance updates & fixes since then, and this might be related to one of them.

Not sure if following from ConfD 7.3 fits your YANG models scenario, but it mentions 7.1 explicitly as one having lower perf. (quote from ConfD CHANGES file):

  - confd: The performance of ConfD, when dumping out a big configuration,
    e.g. with NETCONF get-config, on a system with many 'when' statements
    and many top-level nodes, was low in ConfD-7.1 compared to older ConfD
    versions. The performance has now been improved, and expected to be on
    par with older versions.