Pycharm Django Debugging is really slow

匿名 (未验证) 提交于 2019-12-03 01:38:01

问题:

I have a moderate size website but it takes about 30 seconds for PyCharm to start Runserver and be ready to run the app. If I "Run" the app instead of "Debugging" it will only take about 3 seconds to start.

What are some of the things I can do speed up the code change and debugging cycle. I am using a decent MBP with 16Gb of RAM. So hardware is not the issue.

I have excluded /media files from the project. I don't any other large number of files that will cause indexing problems I am using both Postgres and Mongo db. I am running Django 1.7 + a dozen of packages like:

dj-static==0.0.6 django-annoying==0.8.1 django-appconf==1.0.1 django-bootstrap-form==3.2 django-bootstrap-pagination==1.5.1 django-compressor==1.5 django-extensions==1.5.5 django-filter==0.10.0                               django-guardian==1.2.5 django-storages-redux==1.2.3 django-widget-tweaks==1.3 djangorestframework==3.1.2                         django-jinja==1.4.1 

This is debug output:

/Users/user1/.virtualenvs/env-test/bin/python "/Applications/PyCharm 4.5 EAP.app/Contents/helpers/pydev/pydevd.py" --multiproc --save-signatures --client 127.0.0.1 --port 64097 --file /Users/user1/gitroot/website1/manage.py runserver 0.0.0.0:8000 --verbosity 2 Connected to pydev debugger (build 141.1245) pydev debugger: process 63926 is connecting  pydev debugger: process 63954 is connecting  Performing system checks...  System check identified no issues (0 silenced). You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them. June 03, 2015 - 09:08:52 Django version 1.7.7, using settings 'myproject.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C. 

UPDATE: Since this post Pycharm has the ability to use Cython as the interpreter. I think that has improved things somewhat. I also moved to use Runserverplus which I think runs faster.

回答1:

Well, the debugger is just slow and there is not much you can do about it. Just don't use the debugger unless you absolutely need it (i.e. you are troubleshooting a particularly elusive bug).

I can think of only one thing that may speed up the PyCharm's debugger and that is to turn off the "Collect run-time types information for code insight" setting (located under File > Settings > Build, Execution, Deployment > Python Debugger).



回答2:

For me the issue imporved when I remembered I had enabled the debugger to collect type information.

  • Hit Ctrl-Shift-A or search under Settings > Build, Execution, Deployment > Python Debugger for collect run-time types information for code insight

  • Un-check the box and hit apply

  • See if this helps

I run Pycharm Community 5.0.1



回答3:

I noticed the original poster's debug output doesn't include the message about cython. I came to this post because I couldn't figure out why my pycharm debug was so slow, but later I realized a suggestion for speeding up the debugger is right here in my debug output.

"<some-path-to-python>/python" "/Applications/PyCharm.app/Contents/helpers/pydev/setup_cython.py" build_ext --inplace 

I hope folks have tried that. I guess this answer is for the non-output readers of the world.



回答4:

Need to experiment on these, taken from Jetbrain blog:

  1. delete all breakpoints
  2. turn off tracing exceptions
  3. no runtime type insights

But also look at disabling Django model checking etc to speed up.

I'v used a patch to speed up test cases, 10x faster to run. So, if you do TDD, functions are less heavier than views. It let you resolve bug quickly.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!