396e4e0 optimize aug_match() query for all ifcfg files related to an interface

Authored and Committed by Laine Stump 8 years ago
    optimize aug_match() query for all ifcfg files related to an interface
    
    This resolves:
    
     https://bugzilla.redhat.com/show_bug.cgi?id=1269613
    
    The original augeas search term used by netcf to find, for example, all the
    ifcfg files associated with device "br1" was:
    
         "/files/etc/sysconfig/network-scripts/*[ "
         "DEVICE = 'br1' or BRIDGE = 'br1' or MASTER = 'br1' or MASTER = "
         "../*[BRIDGE = 'br1']/DEVICE ]/DEVICE"
    
    This is *extremely* inefficient - on a test host with 514 host
    bridges, each with an attached vlan interface, a dumpxml of all
    toplevel interfaces took 6m40s (*after* installing an augeas that
    included augeas upstream commits a659f09a, 41e989ca, and 23d5e480
    which were all pushed after the augeas-1.4.0 release).
    
    In these two messages:
    
     https://www.redhat.com/archives/augeas-devel/2015-October/msg00003.html
     https://www.redhat.com/archives/augeas-devel/2015-October/msg00004.html
    
    David Lutterkort suggested changing the search term to:
    
      "(/files/etc/sysconfig/network-scripts/*[(DEVICE|BRIDGE|MASTER) = 'br1']"
      "|/files/etc/sysconfig/network-scripts/*[MASTER]"
      "[MASTER = ../*[BRIDGE = 'br1']/DEVICE ])/DEVICE
    
    That's what this patch does. Testing shows that it is functionally
    equivalent, and reduces the dumpxml time in the previously described
    test from 6m40s down to 17 seconds.
    
        
file modified
+34 -10