<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7405">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">config: Speed up ACO & sorcery initialization<br><br>When starting Asterisk in the foreground, there is a perceptible delay<br>when loading modules that use the ACO and sorcery config frameworks.<br>For example, a lightly configured res_pjsip took 853ms to load on my<br>VM.<br><br>I tracked down the slowness to the XPath queries used to associate the<br>relevant documentation with the config options. One improvement was<br>adding a call to xmlXPathOrderDocElems after loading an XML document.<br>From the libxml2 docs:<br><br>  Call this routine to speed up XPath computation on static documents.<br><br>The second change was to remove recursive descent and wildcard<br>operators from the XPath queries. After these changes, res_pjsip takes<br>85ms to load on my VM and there is no longer a perceptible delay when<br>starting Asterisk in the foreground.<br><br>Change-Id: I45d457f1580e26bf5a2b0dab16e8e9ae46dcbd82<br>---<br>M main/config_options.c<br>M main/xml.c<br>2 files changed, 6 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/05/7405/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/config_options.c b/main/config_options.c<br>index 3c0959e..a9a145b 100644<br>--- a/main/config_options.c<br>+++ b/main/config_options.c<br>@@ -998,11 +998,11 @@<br> <br>       /* If we already have a syntax element, bail. This isn't an error, since we may unload a module which<br>      * has updated the docs and then load it again. */<br>-   if ((results = ast_xmldoc_query("//configInfo[@name='%s']/*/configObject[@name='%s']/syntax", module, name))) {<br>+    if ((results = ast_xmldoc_query("/docs/configInfo[@name='%s']/configFile/configObject[@name='%s']/syntax", module, name))) {<br>                return 0;<br>     }<br> <br>- if (!(results = ast_xmldoc_query("//configInfo[@name='%s']/*/configObject[@name='%s']", module, name))) {<br>+  if (!(results = ast_xmldoc_query("/docs/configInfo[@name='%s']/configFile/configObject[@name='%s']", module, name))) {<br>              ast_log(LOG_WARNING, "Cannot update type '%s' in module '%s' because it has no existing documentation!\n", name, module);<br>           return XMLDOC_STRICT ? -1 : 0;<br>        }<br>@@ -1068,7 +1068,7 @@<br>              return XMLDOC_STRICT ? -1 : 0;<br>        }<br> <br>- if (!(results = ast_xmldoc_query("//configInfo[@name='%s']/*/configObject[@name='%s']/configOption[@name='%s']", module, object_name, name))) {<br>+    if (!(results = ast_xmldoc_query("/docs/configInfo[@name='%s']/configFile/configObject[@name='%s']/configOption[@name='%s']", module, object_name, name))) {<br>                ast_log(LOG_WARNING, "Could not find option '%s' with type '%s' in module '%s'\n", name, object_name, module);<br>              return XMLDOC_STRICT ? -1 : 0;<br>        }<br>diff --git a/main/xml.c b/main/xml.c<br>index d32a8c5..d476c1d 100644<br>--- a/main/xml.c<br>+++ b/main/xml.c<br>@@ -96,6 +96,9 @@<br>         ast_log(LOG_NOTICE, "XSLT support not found. XML documentation may be incomplete.\n");<br> #endif /* HAVE_LIBXSLT */<br> <br>+      /* Optimize for XPath */<br>+     xmlXPathOrderDocElems(doc);<br>+<br>        return (struct ast_xml_doc *) doc;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7405">change 7405</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7405"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I45d457f1580e26bf5a2b0dab16e8e9ae46dcbd82 </div>
<div style="display:none"> Gerrit-Change-Number: 7405 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>