elpy
elpy copied to clipboard
Question: Performance Issues because of syntax checks
Performance problems while typing
I am sorry for using the Issue section but the REAMDE.md tells me so and I was not able to find another contact the the "user community". This is not a bug or a feature. Just a problem of a not so well informed and unexperienced emacs and elpy user.
The problem is that emacs (GUI & terminal) becomes quite slow while typing Python code. It looks like that it has to do with on-the-fly syntax checking. But I am not sure.
I can swich of flymake-mode but then I also lose every syntax checks. I need my syntax check minimum when saving a file or better when moving to a new row. But not on every char I type. I like and need the red ! on the line number column and the red underlines.
When I open a comment string with """ of course the rest of the python source file becomes a comment in that moment and that confuses the syntax checker. This is just one of the examples.
Problem with reference docu in minibuffer
Another problem is that I got shown the reference docu (e.g. from pandas.read_csv()) when I enter the relevant row in the code. The docu is shown in a minibuffer. I do not need this. Can be switched of to improve performance.

Solutions
I am sure a lot of things can be modified on elpy. What can I do to modify this?
More details
My current init.el. Or should I post it directly here?
I installed elpy via one of the tutorials on the web. I am using GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2021-01-31, modified by Debian and elpy from melpa. Sorry I am even not able to tell you my elpy version. I do not know where to get it form.
I am not sure what else is working together or under elpy.
On flymake performance
If flymake is really the cause of the slow down, you can delay it execution with :
(setq flymake-no-changes-timeout 5)
Else, you can try profiling to identify what really cause the slowdown (take a look at profiler-start and profiler-report functions).
On reference in minibuffer
That comes from eldoc, so you can deactivate this minor mode to remove it completely. If what bothers you is the fact that it takes a lot of lines, you can play with eldoc-echo-area-use-multiline-p and other eldoc customisation variables.
I hope it helps.
Booth tips are very helpful. I can definitly say that the performance problem was because of flyemake.
I isolated a similar problem when typing docstrings. Detailes and a solution can be found here https://emacs.stackexchange.com/a/63852/12999
Because the subject fit very well I re-opened here instead of creating a new Issue.
Just to summarize the past. We found 3 reasons for performance problems and their solutions which helped a lot. For the special 3 situations there are no performance problems anymore. But I still have performance problems and I thing they are elpy-related or related to one of the underlying components. I monitor my CPU cores (4 logical) in my taskbar ("panel" in linux speech?).
I am not sure what cause it but from time to time when editing a python file one core goes to 100% and emacs freezes for 2-4 seconds.
Just about the machine. It is a Intel(R) Core(TM) i3-4130T CPU @ 2.90GHz with 8 GB RAM. Not much but it should be enough to edit text files and using emacs.
I tried out profiler-report and found this. Any idea about it? There is something with flymake and the line-number-at-pos.
- #<compiled 0x1611155> 28846 90%
- python--flymake-parse-output 28845 90%
- flymake-diag-region 20345 63%
line-number-at-pos 19601 61%
- end-of-thing 744 2%
- bounds-of-thing-at-point 740 2%
- thing-at-point--end-of-sexp 704 2%
+ forward-sexp 704 2%
- thing-at-point--beginning-of-sexp 36 0%
syntax-ppss 28 0%
forward-sexp 4 0%
+ #<compiled 0x1610d55> 36 0%
assoc-default 32 0%
- linum-update-current 1670 5%
+ linum-update 1670 5%
+ command-execute 1181 3%
+ ... 82 0%
+ yas--post-command-handler 48 0%
+ redisplay_internal (C function) 42 0%
+ timer-event-handler 29 0%
+ elpy-rpc--filter 12 0%
+ evil--jump-hook 4 0%
+ undo-auto--add-boundary 2 0%
I am not sure if I used the profiler correct. There is no life report buffer right?
EDIT: I checked the version of related components and did some updates.
- updated emacs itself from
1.26.1to1.27.1(debian-backports-repo). - Emacs package
flymakeupdated to1.1.1(gnu) elpyis1.28.0