mod_python Trac实例性能分析
我想在我们现实世界的 Trac/mod_python 安装中启用侧面日志记录,该安装已经变得相当慢(很多插件,没有那么多票证/页面)。
我可以代理请求对象,或者添加python跟踪(带有每次调用的时间戳)吗?是否有针对此类包装器的机制?
Trac/mod_python 中的主要入口点是
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
,我想我应该安装一个包装器,它可以通过所有插件跟踪 python 调用以进行时序分析。可能的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
cProfile
模块,类似这样的东西应该可以工作:然后应分析每个请求,并将分析数据(显示占用时间)保存在指定位置,每个请求一个带有时间戳的文件。当然,正在运行的进程必须具有该文件的写入权限。
您可以更改源中的文件。
Using the
cProfile
module, 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.
您可能需要查看此页面,其中描述了一个人的识别技术并解决 Trac 性能问题。每当我的 Trac 实例开始变得缓慢时,我就会借鉴那里解释的技术。
Trac wiki 上的 TracPerformance 页面提供了许多有关提高性能的好建议。
此服务器故障问题还发布了一些有用的提示和链接。
You may want to check out this page describing one person's technique for identifying and resolving Trac performance problems. I borrow from the techniques explained there whenever my Trac instance starts to get sluggish.
The TracPerformance page on Trac's wiki has many more good pointers about improving performance.
There are also some useful hints and links posted to this serverfault question.