Change in vdsm[master]: numa: refactor to single pass caps parse

fromani at redhat.com fromani at redhat.com
Tue Mar 1 11:43:27 UTC 2016


Francesco Romani has posted comments on this change.

Change subject: numa: refactor to single pass caps parse
......................................................................


Patch Set 9: Code-Review+1

(3 comments)

seems OK, but I'd like to reduce the length of the chained calls. Partial ACK.

https://gerrit.ovirt.org/#/c/53288/9/lib/vdsm/numa.py
File lib/vdsm/numa.py:

Line 46:     siblings = set()
Line 47:     online_cpus = []
Line 48: 
Line 49:     caps = ET.fromstring(capabilities)
Line 50:     cells = caps.find('host').find('.//cells').findall('cell')
I'm a bit torn because I don't like the chained calls, it is a (light) code smell to me. OTOH, I acknowledge that temporary are useless here.

So, a good solution could be to find a smarter xpath expression to find the cells:

https://docs.python.org/2/library/xml.etree.elementtree.html#elementtree-xpath

could you please try to find such expression?
Line 51: 
Line 52:     for cell in cells:
Line 53:         cell_id = cell.get('id')
Line 54:         meminfo = memory_by_cell(int(cell_id))


Line 52:     for cell in cells:
Line 53:         cell_id = cell.get('id')
Line 54:         meminfo = memory_by_cell(int(cell_id))
Line 55:         topology[cell_id]['totalMemory'] = meminfo['total']
Line 56:         topology[cell_id]['cpus'] = []
(very) minor:

I wonder if

  topology[cell_id] = {
    'totalMemory': meminfo['total'],
    'cpus': [],
  }

is any better. What do you think?
Line 57:         distances[cell_id] = []
Line 58: 
Line 59:         for cpu in cell.find('cpus').findall('cpu'):
Line 60:             topology[cell_id]['cpus'].append(int(cpu.get('id')))


Line 55:         topology[cell_id]['totalMemory'] = meminfo['total']
Line 56:         topology[cell_id]['cpus'] = []
Line 57:         distances[cell_id] = []
Line 58: 
Line 59:         for cpu in cell.find('cpus').findall('cpu'):
same comment as per line 50, albeit less important.
Line 60:             topology[cell_id]['cpus'].append(int(cpu.get('id')))
Line 61:             if cpu.get('siblings') and cpu.get('socket_id'):
Line 62:                 online_cpus.append(cpu.get('id'))
Line 63:                 sockets.add(cpu.get('socket_id'))


-- 
To view, visit https://gerrit.ovirt.org/53288
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie81b5b76523070ec9fd7a6ffe902ffa25da9e3a6
Gerrit-PatchSet: 9
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list