<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Oct 3, 2015 at 3:05 PM, David Lutterkort <span dir="ltr"><<a href="mailto:lutter@watzmann.net" target="_blank">lutter@watzmann.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Oct 1, 2015 at 11:44 AM, Laine Stump <span dir="ltr"><<a href="mailto:laine@redhat.com" target="_blank">laine@redhat.com</a>></span> wrote:<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">But 13 (or even 8) minutes is still a very long time, so I played around a bit in gdb and found that most of the time now seems to be spent in one call to aug_match():<br>
<br>
<br>
  r = aug_match(aug, path, "/files/etc/sysconfig/network-scripts/*[ DEVICE = 'br1' or BRIDGE = 'br1' or MASTER = 'br1' or MASTER = ../*[BRIDGE = 'br1']/DEVICE ]/DEVICE");<br></blockquote><div><br></div></span><div>Whoever wrote that code must have thought they were incredibly clever with this query ;) <br><br></div><div>There's a few ways in which I think this can be sped up: for one, rather than use 'or', we can build an intermediate nodeset for the first three nodesets by matching<br><br><div style="margin-left:40px">(1) /files/etc/sysconfig/network-scripts/*[(DEVICE|BRIDGE|MASTER) = 'br1']/DEVICE<br><br></div>The last term in that 'or' is very expensive since it constitutes a nested loop, with "/files/etc/sysconfig/network-scripts/*" being the outer loop ("for each ifcfg file") and "../*[BRIDGE = 'br1']/DEVICE" being the inner loop ("for each ifcfg file see if it is a BRIDGE and return its DEVICE"). That can be made a little more targetted by using<br><br><div style="margin-left:40px">(2) /files/etc/sysconfig/network-scripts/*/MASTER[ . = ../*[BRIDGE = 'br1']/DEVICE ]<br><br></div>so that we only trigger the inner loop for ifcfg files that actually have a MASTER entry. This helps if you don't have bonds - I suspect, if there are any bonds on the system, the query will still be very expensive.<br></div></div></div></div></blockquote><div><br></div><div>I shouldn't computer on weekends: this part is total nonsense. It needs to be<br><br><div style="margin-left:40px"> /files/etc/sysconfig/network-scripts/*[MASTER][MASTER = ../*[BRIDGE = 'brvlan42']/DEVICE ]<br></div><br></div><div>The first '[MASTER]' makes sure we only run the second predicate "[MASTER = ../*[BRIDGE = 'brvlan42']/DEVICE ]" with the expensive loop on files that actually have a MASTER entry.<br><br></div><div>Attached updated augcmds.txt and output - the timings are roughly in the same ballpark as mentioned in my previous email.<br></div><br><br></div></div></div>