Commit 9d52e441 authored by rossp's avatar rossp

Avoid sorting the working set and requirements when it won't be logged.

When profiling a simple buildout with 10 parts with identical and
large working sets, this resulted in a decrease of run time from
93.411 to 15.068 seconds, about a 6 fold improvement.  To see the
benefit be sure to run without any increase in verbosity ("-v"
option).

git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@124059 62d5b8a3-27da-0310-9561-8e5933582275
parent 689ae2d3
...@@ -4,6 +4,13 @@ Change History ...@@ -4,6 +4,13 @@ Change History
1.6.0 (unreleased) 1.6.0 (unreleased)
================== ==================
- Avoid sorting the working set and requirements when it won't be
logged. When profiling a simple buildout with 10 parts with
identical and large working sets, this resulted in a decrease of run
time from 93.411 to 15.068 seconds, about a 6 fold improvement. To
see the benefit be sure to run without any increase in verbosity
("-v" option). (rossp)
- The buildout init command now accepts distribution requirements and - The buildout init command now accepts distribution requirements and
paths to set up a custom interpreter part that has the distributions paths to set up a custom interpreter part that has the distributions
or parts in the path. For example:: or parts in the path. For example::
......
...@@ -1850,6 +1850,15 @@ class MissingDistribution(zc.buildout.UserError): ...@@ -1850,6 +1850,15 @@ class MissingDistribution(zc.buildout.UserError):
return "Couldn't find a distribution for %r." % str(req) return "Couldn't find a distribution for %r." % str(req)
def _log_requirement(ws, req): def _log_requirement(ws, req):
if not logger.isEnabledFor(logging.DEBUG):
# Sorting the working set and iterating over it's requirements
# is expensive, so short cirtuit the work if it won't even be
# logged. When profiling a simple buildout with 10 parts with
# identical and large working sets, this resulted in a
# decrease of run time from 93.411 to 15.068 seconds, about a
# 6 fold improvement.
return
ws = list(ws) ws = list(ws)
ws.sort() ws.sort()
for dist in ws: for dist in ws:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment