Change in vdsm[master]: netinfo: optimize ipaddr retrieval

fromani at redhat.com fromani at redhat.com
Fri Feb 7 09:05:09 UTC 2014


Francesco Romani has posted comments on this change.

Change subject: netinfo: optimize ipaddr retrieval
......................................................................


Patch Set 4: Code-Review+1

(1 comment)

http://gerrit.ovirt.org/#/c/23518/4/lib/vdsm/netlink.py
File lib/vdsm/netlink.py:

Line 95:         with _nl_link_cache() as link_cache:  # For index to label resolution
Line 96:             addr = _nl_cache_get_first(addr_cache)
Line 97:             while addr:
Line 98:                 yield _addr_info(link_cache, addr)
Line 99:                 addr = _nl_cache_get_next(addr)
Please note that I'm OK with the current code and that's just a wild idea, feel free to ignore.

*if* we can swap the order of the two with-s above, and if we can rearrange a bit things, there could be another factoring opportunity, something along those lines:

  def iter_cache(get_cache, visitor):
      with get_cache() as cache:
          item = _nl_cache_get_first(cache):
          while item:
              yield visitor(cache, item)
              item = _nl_cache_get_next(item)

  def iter_links():
      iter_cache(_nl_link_cache, _link_info)


  def iter_addrs():
      with _nl_link_cache() as link_cache:
          def _visit(unused, addr):
              return _addr_info(link_cache, addr)
          iter_cache(_nl_addr_cache, _visit)


Just written now on the fly, feel free to change with partial, lambdas or whatever.
However this is maybe too much, so again it can stay like it is.
Line 100: 
Line 101: 
Line 102: def get_link(name):
Line 103:     """Returns the information dictionary of the name specified link."""


-- 
To view, visit http://gerrit.ovirt.org/23518
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I571529f6dd379ffb317625fd9e2abd6b5ae88696
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Ondřej Svoboda <osvoboda at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list