Skip to content

Commit

Permalink
Avoid sorting the working set and requirements when it won't be logged.
Browse files Browse the repository at this point in the history
Backport 124059 from trunk.
  • Loading branch information
rpatterson committed Jan 16, 2012
1 parent a8cbb42 commit e621a0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions src/zc/buildout/easy_install.py
Expand Up @@ -1200,6 +1200,15 @@ def __str__(self):
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:
Expand Down

0 comments on commit e621a0c

Please sign in to comment.