threading.py._release_save & socket.py.accept cpu时间

发布于 2024-10-30 06:14:22 字数 473 浏览 0 评论 0原文

我正在创建一个应用程序,我希望尽可能地限制其资源占用。 我注意到我的应用程序在低负载下平均消耗 4% 的 CPU 使用率,尽管这并不一定意味着坏事,但我想知道这到底来自哪里。

我开始使用分析软件(yappi),虽然所有线程似乎都没有花费太多时间,但有两个例外:

name                                 #n       tsub       ttot       tavg
Thread         1402.. ../lib/python2.6/socket.py.accept:19 340      678.6799.. 
..bmit_listene 1402.. ..n2.6/threading.py._release_save:21 5032     932.8961..

这些方法/类是否已知为“资源密集型”? 您有与这些相关的任何绩效改进技巧吗?

谢谢,

杰伊

I'm creating an app of which I like to limit its resource footprint as much as possible.
I noticed my app is consuming by average 4% cpu usage on a low load and although that doesn't necessarily mean a bad thing, I was wondering where exactly this comes from.

I started to use a profiling software (yappi) and while all threads not seem to spend much time there are 2 exceptions:

name                                 #n       tsub       ttot       tavg
Thread         1402.. ../lib/python2.6/socket.py.accept:19 340      678.6799.. 
..bmit_listene 1402.. ..n2.6/threading.py._release_save:21 5032     932.8961..

Are these methods/classes known to be "resource intensive"?
Do you have any performance improving tips related to these?

Thanks,

Jay

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千寻… 2024-11-06 06:14:22

分析器中阻塞调用的时间意义不大。当进行阻塞调用时,线程被挂起并且其他线程运行,当阻塞调用返回时,在其他线程中花费的时间也会添加到被调用函数的总时间中。请参阅:Yappi 的多线程统计

更新:v0.62 支持 CPU 时间分析,有效解决与阻塞函数的多线程分析相关的所有问题。

Timings for the blocking calls in profilers are not very meaningful. When a blocking call is made that thread is suspended and other threads run, when blocking call returns back the time spent in other threads is also added to the total time of the called function. See this: Multithreaded Statistics for Yappi

Update: v0.62 supports CPU time profiling which effectively solves all the problems related with multithreaded profiling of blocking functions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文