Commit e621a0ce authored by Ross Patterson's avatar Ross Patterson

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

Backport 124059 from trunk.
parent a8cbb422
......@@ -4,6 +4,13 @@ Change History
1.4.5 (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)
- Introduce a cache for the expensive `buildout._dir_hash` function.
- Remove duplicate path from script's sys.path setup.
......
......@@ -1200,6 +1200,15 @@ class MissingDistribution(zc.buildout.UserError):
return "Couldn't find a distribution for %r." % str(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.sort()
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