php-mode icon indicating copy to clipboard operation
php-mode copied to clipboard

php-mode's call to php-syntax-propertize-function makes visiting large files rather slow

Open phil-s opened this issue 6 years ago • 7 comments

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?

phil-s avatar Dec 17 '18 03:12 phil-s

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.

mallt avatar Dec 17 '18 20:12 mallt

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%

odysseyalive avatar Apr 19 '19 07:04 odysseyalive

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!

odysseyalive avatar Apr 25 '19 02:04 odysseyalive

Ok great! I will give it some more testing to check if I still notice the partial font locking issue.

mallt avatar Apr 25 '19 05:04 mallt

@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!

mallt avatar May 22 '19 20:05 mallt

Emacs: 27.0.50 php-mode: 20190522.1249

I loaded some of my larger projects. It works beautifully with no apparent issues. Thank you!

odysseyalive avatar May 22 '19 21:05 odysseyalive

@bridgesense Thanks!

I will release v1.21.3 tonight or tomorrow if there is no problem with this version.

zonuexe avatar May 23 '19 07:05 zonuexe