launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04499
[Merge] lp:~gary/launchpad/bug821487 into lp:launchpad
Gary Poster has proposed merging lp:~gary/launchpad/bug821487 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #821487 in Launchpad itself: "++profile++ code uses chameleon, forcing multiple second compile step for LP"
https://bugs.launchpad.net/launchpad/+bug/821487
For more details, see:
https://code.launchpad.net/~gary/launchpad/bug821487/+merge/70594
This is a simple branch to rip out the Chameleon dependency of ++profile++, and thereby speed up the build by a few seconds. It is a drop in the bucket compared to the build time for Mailman and the wadl, but it is something.
Lint is happy except for some nonsense that seems to imply that tal confuses it, or something:
./lib/lp/services/profile/profile.pt
6: junk after document element
Thanks!
Gary
--
https://code.launchpad.net/~gary/launchpad/bug821487/+merge/70594
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gary/launchpad/bug821487 into lp:launchpad.
=== modified file '.bzrignore'
--- .bzrignore 2011-07-05 14:30:42 +0000
+++ .bzrignore 2011-08-05 16:29:06 +0000
@@ -71,7 +71,6 @@
lib/canonical/launchpad-buildd_*_source.changes
lib/canonical/buildd/debian/*
lib/canonical/buildd/launchpad-files/*
-*.pt.py
.project
.pydevproject
librarian.log
=== modified file 'Makefile'
--- Makefile 2011-07-26 21:03:26 +0000
+++ Makefile 2011-08-05 16:29:06 +0000
@@ -232,14 +232,11 @@
$(subst $(PY),,$(BUILDOUT_BIN)): $(PY)
-# bin/compile_templates is responsible for building all chameleon templates,
-# of which there is currently one, but of which many more are coming.
compile: $(PY) $(BZR_VERSION_INFO)
mkdir -p /var/tmp/vostok-archive
${SHHH} $(MAKE) -C sourcecode build PYTHON=${PYTHON} \
LPCONFIG=${LPCONFIG}
${SHHH} LPCONFIG=${LPCONFIG} ${PY} -t buildmailman.py
- bin/compile_templates
test_build: build
bin/test $(TESTFLAGS) $(TESTOPTS)
@@ -269,8 +266,9 @@
> ${LPCONFIG}-nohup.out 2>&1 &
run_all: check_schema inplace stop
- bin/run -r librarian,sftp,forker,mailman,codebrowse,google-webservice,memcached \
- -i $(LPCONFIG)
+ bin/run \
+ -r librarian,sftp,forker,mailman,codebrowse,google-webservice,memcached \
+ -i $(LPCONFIG)
run_codebrowse: build
BZR_PLUGIN_PATH=bzrplugins $(PY) scripts/start-loggerhead.py -f
@@ -372,8 +370,7 @@
fi
find . -path ./eggs -prune -false -o \
-type f \( -name '*.o' -o -name '*.so' -o -name '*.la' -o \
- -name '*.lo' -o -name '*.py[co]' -o -name '*.dll' -o \
- -name '*.pt.py' \) \
+ -name '*.lo' -o -name '*.py[co]' -o -name '*.dll' \) \
-print0 | xargs -r0 $(RM)
$(RM) -r lib/mailman
$(RM) -rf $(LP_BUILT_JS_ROOT)/*
=== modified file 'lib/lp/services/profile/profile.pt'
--- lib/lp/services/profile/profile.pt 2011-02-03 20:55:58 +0000
+++ lib/lp/services/profile/profile.pt 2011-08-05 16:29:06 +0000
@@ -3,12 +3,23 @@
Click to REVEAL profiling information
</div>
</div>
-<div class="profiling_info" id="profiling_info">
+<div class="profiling_info" id="profiling_info"
+ tal:define="actions options/actions;
+ help actions/help|nothing;
+ log actions/log|nothing;
+ show actions/show|nothing;
+ always_log options/always_log;
+ dump_path options/dump_path;
+ inlinetime options/inlinetime|nothing;
+ totaltime options/totaltime|nothing;
+ callcount options/callcount|nothing;
+ oops options/oops|nothing;
+ ">
<div class="hide_reveal_profiling" id="hide_profiling">
Click to HIDE profiling information
</div>
<h1>Profiling Information</h1>
- <tal:block condition="'help' in actions">
+ <tal:block condition="help">
<h2>Help</h2>
<p>Hi. I see you are using a <code>++profile++</code> request.
<tal:block condition="always_log">You have configured every request
@@ -16,7 +27,7 @@
the <code>[profiling]</code> section of your launchpad-lazr.conf, so
you'll always see some logging information below. In order to also
get immediate profiling results in the browser, use
- <code>++profile++show</code>.</tal:block> <tal:block condition="not
+ <code>++profile++show</code>.</tal:block> <tal:block condition="not:
always_log">In order to get profiling results, you need to ask for
an HTML view (<code>++profile++show</code>), a KCacheGrind-friendly
log on the filesystem (<code>++profile++log</code>), or both
@@ -29,14 +40,15 @@
be necessary.</p>
</tal:block>
<h2>Log information</h2>
- <tal:block condition="'log' not in actions">
+ <tal:block condition="not:log">
<p>Profile was not logged to file.</p>
<p>Use <code>++profile++log</code> in your URL in order to log the
information to file for later KCacheGrind analysis (or
<code>++profile++log,show</code> to see both the log information and
- immediate results).</p>
+ immediate results). Profiles are logged to
+ <tal:block replace="dump_path" />.</p>
</tal:block>
- <tal:block condition="'log' in actions">
+ <tal:block condition="log">
<p tal:condition="always_log"><strong>You have configured every
request to have a full profile log</strong>, via the
<code>profile_all_requests: True</code> in the
@@ -49,12 +61,12 @@
>dev wiki</a> may have more information on how to use this.</p>
</tal:block>
<h2>Profile quick view</h2>
- <tal:block condition="'show' not in actions">
+ <tal:block condition="not:show">
<p>Use <code>++profile++show</code> in your URL in order to see
immediate profile results (or <code>++profile++log,show</code> to
see both the log information and immediate results).</p>
</tal:block>
- <tal:block condition="'show' in actions">
+ <tal:block condition="show">
<h3>Top Inline Time</h3>
<pre tal:content="inlinetime" />
<h3>Top Total Time</h3>
=== modified file 'lib/lp/services/profile/profile.py'
--- lib/lp/services/profile/profile.py 2011-02-28 07:14:32 +0000
+++ lib/lp/services/profile/profile.py 2011-08-05 16:29:06 +0000
@@ -13,8 +13,7 @@
import StringIO
from bzrlib.lsprof import BzrProfiler
-from chameleon.zpt.template import PageTemplateFile
-from zope.app.publication.interfaces import IBeforeTraverseEvent
+from zope.pagetemplate.pagetemplatefile import PageTemplateFile
from zope.app.publication.interfaces import IEndRequestEvent
from zope.component import (
adapter,
@@ -43,13 +42,15 @@
_profilers = threading.local()
+
def before_traverse(event):
- """Handle profiling when enabled via the profiling.enabled feature flag."""
- # This event is raised on each step of traversal so needs to be lightweight
- # and not assume that profiling has not started - but this is equally well
- # done in _maybe_profile so that function takes care of it. We have to use
- # this event (or add a new one) because we depend on the feature flags
- # system being configured and usable, and on the principal being known.
+ "Handle profiling when enabled via the profiling.enabled feature flag."
+ # This event is raised on each step of traversal so needs to be
+ # lightweight and not assume that profiling has not started - but this is
+ # equally well done in _maybe_profile so that function takes care of it.
+ # We have to use this event (or add a new one) because we depend on the
+ # feature flags system being configured and usable, and on the principal
+ # being known.
try:
if getFeatureFlag('profiling.enabled'):
_maybe_profile(event)
@@ -67,7 +68,7 @@
def _maybe_profile(event):
"""Setup profiling as requested.
-
+
If profiling is enabled, start a profiler for this thread. If memory
profiling is requested, save the VSS and RSS.
@@ -76,7 +77,8 @@
try:
if _profilers.profiling:
# Already profiling - e.g. called in from both start_request and
- # before_traverse, or by successive before_traverse on one request.
+ # before_traverse, or by successive before_traverse on one
+ # request.
return
except AttributeError:
# The first call in on a new thread cannot be profiling at the start.
@@ -119,7 +121,7 @@
# Create a timestamp including milliseconds.
now = datetime.fromtimestamp(da.get_request_start_time())
timestamp = "%s.%d" % (
- now.strftime('%Y-%m-%d_%H:%M:%S'), int(now.microsecond/1000.0))
+ now.strftime('%Y-%m-%d_%H:%M:%S'), int(now.microsecond / 1000.0))
pageid = request._orig_env.get('launchpad.pageid', 'Unknown')
oopsid = getattr(request, 'oopsid', None)
content_type = request.response.getHeader('content-type')
@@ -130,8 +132,10 @@
_major, _minor, content_type_params = parse(content_type)
is_html = _major == 'text' and _minor == 'html'
template_context = {
- 'actions': actions,
+ # Dicts are easier for tal expressions.
+ 'actions': dict((action, True) for action in actions),
'always_log': config.profiling.profile_all_requests}
+ dump_path = config.profiling.profile_dir
if _profilers.profiler is not None:
prof_stats = _profilers.profiler.stop()
# Free some memory.
@@ -150,9 +154,8 @@
filename = '%s-%s-%s-%s.prof' % (
timestamp, pageid, oopsid,
threading.currentThread().getName())
- dump_path = os.path.join(config.profiling.profile_dir, filename)
+ dump_path = os.path.join(dump_path, filename)
prof_stats.save(dump_path, format="callgrind")
- template_context['dump_path'] = os.path.abspath(dump_path)
if is_html and 'show' in actions:
# Generate raw OOPS results.
f = StringIO.StringIO()
@@ -164,10 +167,11 @@
f = StringIO.StringIO()
prof_stats.pprint(file=f)
template_context[name] = f.getvalue()
+ template_context['dump_path'] = os.path.abspath(dump_path)
if actions and is_html:
# Hack the new HTML in at the end of the page.
encoding = content_type_params.get('charset', 'utf-8')
- added_html = template.render(**template_context).encode(encoding)
+ added_html = template(**template_context).encode(encoding)
existing_html = request.response.consumeBody()
e_start, e_close_body, e_end = existing_html.rpartition(
'</body>')
=== modified file 'setup.py'
--- setup.py 2011-07-15 15:55:34 +0000
+++ setup.py 2011-08-05 16:29:06 +0000
@@ -83,7 +83,7 @@
'zope.app.apidoc',
'zope.app.appsetup',
'zope.app.component',
- 'zope.app.dav', # ./zcml/package-includes/dav-configure.zcml
+ 'zope.app.dav', # ./zcml/package-includes/dav-configure.zcml
'zope.app.error',
'zope.app.exception',
'zope.app.file',
@@ -112,7 +112,7 @@
'zope.formlib',
'zope.i18n',
'zope.interface',
- 'zope.hookable', # indirect, via zope.app.component
+ 'zope.hookable', # indirect, via zope.app.component
'zope.lifecycleevent',
'zope.location',
'zope.login',
@@ -129,7 +129,7 @@
'zope.testbrowser',
'zope.testing',
'zope.traversing',
- 'zope.viewlet', # only fixing a broken dependency
+ 'zope.viewlet', # only fixing a broken dependency
# Loggerhead dependencies. These should be removed once
# bug 383360 is fixed and we include it as a source dist.
'Paste',
@@ -149,7 +149,7 @@
]
),
entry_points=dict(
- console_scripts=[ # `console_scripts` is a magic name to setuptools
+ console_scripts=[ # `console_scripts` is a magic name to setuptools
'apiindex = lp.scripts.utilities.apiindex:main',
'killservice = lp.scripts.utilities.killservice:main',
'jsbuild = lp.scripts.utilities.js.jsbuild:main',
@@ -159,8 +159,6 @@
'start_librarian '
'= canonical.launchpad.scripts.runlaunchpad:start_librarian',
'ec2 = devscripts.ec2test.entrypoint:main',
- 'compile_templates '
- '= canonical.launchpad.scripts:execute_zcml_for_scripts',
]
),
)