I would like to enable a side-logging in our real-world Trac/mod_python installation that has gotten quite slow (lots of plugins, not so many tickets/pages).
Can I proxy the request object, or add a python trace (with timestamps for each call) somehow? Is there e mechanism for these kind of wrappers?
The main entry point in Trac/mod_python is
def handler(req):
pkg_resources.require('Trac==%s' % VERSION)
gateway = ModPythonGateway(req, req.get_options())
from trac.web.main import dispatch_request
gateway.run(dispatch_request)
return apache.OK
and there I guess I should install a wrapper, that can trace python calls through all plugins for timing analysis. Possible?
Using the
cProfilemodule, something like this should work:Then each request should be profiled and the profiling data (showing what takes up time) saved in the specified location, one timestamped file per request. The running process, of course, must have write privileges to the file.
You can change the file in the source.