php-mode
php-mode copied to clipboard
php-mode's call to php-syntax-propertize-function makes visiting large files rather slow
The size of file involved here makes this an edge case, but I have a 450K file of machine-generated PHP, and just opening the file on even a reasonably quick PC takes 3 seconds, which is mostly accounted for by that forced call to php-syntax-propertize-function
at the end of php-mode
:
- php-mode 2208 92%
- php-syntax-propertize-function 2080 87%
- syntax-ppss 1996 83%
Does anyone have ideas for how to circumvent or reduce that?
I can see that #294 introduced this call because Emacs 25 had ceased to do it automatically, which really makes me wonder whether there's an existing Better Way which Emacs 25 expects modes to be utilising?
NEWS.25 says:
** 'syntax-propertize' is now automatically called on-demand during forward parsing functions like 'forward-sexp'.
Which sounds like ideally this up-front effort wouldn't be needed at all; but presumably it turned out that it was in practice?
Good point! It seems this call was also removed from js-mode
some time ago. I quickly tried to comment out the call locally, but then it seems larger files only get partially font locked, so I think more configuration will be needed to make this work.
I updated recently and I'm having to axe php-mode on relatively small files around 2600 lines of code. I don't suppose there is a temporary hack someone would like to share?
Emacs 27.0.50
- parse-partial-sexp 6670 78%
- internal--syntax-propertize 6669 78%
- syntax-propertize 6664 77%
- php-syntax-propertize-function 6004 70%
- syntax-ppss 5936 69%
- php-syntax-propertize-function 6004 70%
- syntax-propertize 6664 77%
- internal--syntax-propertize 6669 78%
Good point! It seems this call was also removed from
js-mode
some time ago. I quickly tried to comment out the call locally, but then it seems larger files only get partially font locked, so I think more configuration will be needed to make this work.
I took your suggestion and haven't noticed any partial font locking. In any case, it does make a tremendous speed difference. Thanks!
Ok great! I will give it some more testing to check if I still notice the partial font locking issue.
@phil-s @bridgesense This slowdown should be fixed by @zonuexe with PR #531. Could you perhaps verify this with the latest MELPA version of php-mode? Thanks!
Emacs: 27.0.50 php-mode: 20190522.1249
I loaded some of my larger projects. It works beautifully with no apparent issues. Thank you!
@bridgesense Thanks!
I will release v1.21.3
tonight or tomorrow if there is no problem with this version.