使用 WingIDE 时 Google App Engine 开发服务器启动缓慢

发布于 2024-09-27 20:54:50 字数 455 浏览 6 评论 0原文

我正在 Google App Engine 上进行开发。我正在使用 WingIDE(一个 python IDE)在开发服务器上进行调试。我的数据存储中有数千个实体,我可以看到,当开发服务器启动时,它必须通过 DatastoreFileStub.Read() 并对每个实体执行一些操作。

问题是,当我通过 WingIDE 运行开发服务器时,它运行速度非常慢。我将一些分析日志代码放入谷歌应用程序引擎中以获取峰值。

当我在命令行上运行开发服务器时,我收到以下消息:

Finished read 10374 Entites in 10.17 秒,每秒 1019 次

但是,当我通过 WingIDE 运行开发服务器时,我收到以下消息:

< code>在 52.44 秒内完成读取 10374 个实体,每秒 197 个

有人知道为什么 WingIDE 会慢 5 倍吗?

I'm developing on Google App Engine. I am using WingIDE (a python IDE) to debug on the development server. I have several thousand entities in my datastore and I can see that when the development server starts up, it has to go through DatastoreFileStub.Read() and do something which each entity.

The problem is, when I run the development server through WingIDE it runs horrendously slow. I put some profiling logging code into the google app engine to take a peak.

When I run the development server on the command line, I get the following message:

Finished reading 10374 Entites in 10.17 seconds, 1019 per second

When I run the development server through WingIDE however, I get this:

Finished reading 10374 Entites in 52.44 seconds, 197 per second

Anyone have an idea why WingIDE would be 5 times slower?

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

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

发布评论

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

评论(2

毅然前行 2024-10-04 20:54:50

可能是因为您已经连接了调试器 - 调试器通过检测所有内容而大大减慢了代码速度,并且反序列化数据存储区需要大量工作。

使用 --use_sqlite 标志将启用基于 sqlite 的实验性本地数据存储,这应该需要更少的启动时间。但请注意,当您切换到数据存储时,它会要求您擦除数据存储。

Probably because you've got a debugger hooked up - debuggers slow code down a lot by instrumenting everything, and deserializing your datastore is a lot of work.

Using the --use_sqlite flag will enable an experimental sqlite-based local datastore, which should require less startup time. Note that it'll require you to wipe your datastore when you switch to it, however.

待天淡蓝洁白时 2024-10-04 20:54:50

一种想法是在启动完成后使用wingdbstub开始调试。您需要在某处代码中添加“导入 wingdbstub”,但这可以在启动后在任何地方调用。当然,该模块必须位于 python 路径上,IDE 必须配置为侦听连接,并且您需要设置一些基本的安全性 - 这些都在 http://wingware.com/doc/debug/importing-the-debugger

还有一个 API,因此您可以开始尽早进行调试,并在调试器开销太大的地方暂时将其关闭。请参阅 http://wingware.com/doc/debug/debugger-api

调试器开销为这是一件棘手的事情(至少对于 CPython 来说),因为它与执行的 Python 字节码数量成正比。通过查看 Python 代码,解释器运行字节代码的时间以及 C/C++ 库或 Python 内部的时间并不总是显而易见。如果它们执行的工作大部分是在 Python 中完成的,那么诸如迭代大量数据的嵌套 Python 循环之类的东西在调试器中最终会慢得多。在许多事情中,大部分工作实际上是在 Python 内部或库代码中完成的,因此调试器不会减慢速度。

One idea is to use wingdbstub to start debugging after startup is done. You need to add an 'import wingdbstub' to code somewhere, but that could anywhere called after startup. Of course the module has to be on the python path, the IDE has to be configured to listen for connections, and you need to set up some basic security -- which is all described in detail at http://wingware.com/doc/debug/importing-the-debugger

There is also an API so you could start debugging earlier and temporarily turn it off in places where the debugger overhead is too much. See http://wingware.com/doc/debug/debugger-api

Debugger overhead is a tricky thing (at least for CPython) since it's proportional to number of Python byte codes executed. It's not always obvious from looking at Python code how much time is in the interpreter running byte codes and how much time is in C/C++ libraries or Python internals. Something like nested Python loops that iterate over large amounts of data will end up being much slower in a debugger if the work they perform is mostly done in Python. In many things most of the work is actually done in Python internals or library code so the debugger won't slow things down as much.

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