将 Psyco 混合到我的项目中有哪些风险(如果有)?
我从事一个大型金融定价应用程序的工作,其中有一些长时间运行的计算。我们已经确定了一些可以通过选择性应用 psyco 来加速的功能。我的管理层已要求对成本和费用进行评估。将 psyco 添加到我们的堆栈中的好处。
考虑到我的项目的关键性质,如果“性能增强”可能会降低可靠性,这是不可接受的。我读到,使用 psyco 可以以使用更多内存为代价获得额外的性能。我担心这可能会成为一个问题。
我是这样做的:
@psyco.proxy
def my_slow_function(xxx):
总的来说,我们期望将 psyco 应用到不超过 15 个函数 - 这些函数使用得非常频繁。该库中有数千个函数,因此这只影响我们代码的一小部分。所有函数都很小、数学化且无状态。
- 是否可能存在使用更多内存的风险?
- 在将此组件添加到我们长期建立的库中时,我们可能会遇到任何其他问题吗?
仅供参考,平台是 Windows 32 位 XP 上的 Python 2.4.4
更新:似乎主要的潜在风险是由于程序需要比添加 psyco 之前更多的内存来运行,所以理想情况下,我想找到一种方法来查看是否添加 psyco 会极大地改变系统的内存需求。
I work on a large financial pricing application in which some long running calculations. We have identified some functions which can be sped up by the selective application of psyco. My management have requested an assessment of the costs & benefits of adding psyco into our stack.
Given the critical nature of my project, it's not acceptable if a "performance enhancement" can potentially reduce reliability. I've read that using psyco gets additional performance at the cost of more memory used. I'm worried that this could be a problem.
I'm doing it like this:
@psyco.proxy
def my_slow_function(xxx):
In all, we expect to apply psyco to no more than 15 functions - these are used very heavily. There are thousands of functions in this library, so this is only affecting a tiny sub-set of of our code. All of the functions are small, mathematical and stateless.
- Is there likely to be a risk that this will use substantially more memory
- Are there any other problems we might encounter when adding this component to our long established library?
FYI, platform is Python 2.4.4 on Windows 32bit XP
UPDATE: It seems that the main potential risk is due to a program requiring more memory to run than before psyco was added, so ideally I'd like to find a way to see if adding psyco dramatically changes the memory requirements of the system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不尝试分析它呢? Psyco 有一个非常详细的日志记录设施:
另请注意,内存使用情况是可配置的:
Why not try profiling it? Psyco has a pretty detailed logging facility:
Note also that the memory usage is configurable:
Psyco 是一个 JIT 编译器。如果你的函数是无状态的,那么除了更多的内存之外,几乎没有任何缺点。
Psyco is a JIT compiler. If your function are stateless, then there should be almost no draw back except more memory.