From 70786c65773ca4e4bc8875842e733a0bcabd4ed4 Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Fri, 23 Jan 2015 15:50:40 -0700 Subject: [PATCH] Refactor logging in loop to only log debug messages once Logging entries in a loop to a file can be expensive for a large number of objects (e.g. ports) in a loop. Rather than perform the overhead of logging a debug entry for each line within the hosts file, move the debug trace of the contents to after the loop to bulk up the I/O operations. Conflicts: neutron/agent/linux/dhcp.py (cherry-picked from d93e0098ebd5f333d6f496f10a663cd4351410ae) Change-Id: I3ad7864eeb2f959549ed356a1e34fa18804395cc Closes-Bug: #1414218 --- neutron/agent/linux/dhcp.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index ddf9f444c13..e5ffa7fbaa0 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -519,10 +519,6 @@ class Dnsmasq(DhcpLocalProcess): if netaddr.valid_ipv6(ip_address): ip_address = '[%s]' % ip_address - LOG.debug(_('Adding %(mac)s : %(name)s : %(ip)s'), - {"mac": port.mac_address, "name": name, - "ip": ip_address}) - if getattr(port, 'extra_dhcp_opts', False): buf.write('%s,%s,%s,%s%s\n' % (port.mac_address, name, ip_address, @@ -532,7 +528,8 @@ class Dnsmasq(DhcpLocalProcess): (port.mac_address, name, ip_address)) utils.replace_file(filename, buf.getvalue()) - LOG.debug(_('Done building host file %s'), filename) + LOG.debug('Done building host file %s with contents:\n%s', filename, + buf.getvalue()) return filename def _read_hosts_file_leases(self, filename):