-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor performance in largish files #676
Comments
I'm running into the same issue, except with longer lag and smaller files (running Doom). According to the profiler, most of my CPU time is spent in |
Following through a little more, it may be that it's spending a lot of time trying to syntax highlight areas of code that have been commented out (because they are unused). I got some performance improvement by removing these sections (not a permanent solution as the code is not mine). Is there any way of turning off e.g. |
Like this? (advice-add 'php--syntax-propertize-quotes-in-comment :override #'ignore) |
I had cause to revisit this, and the syntax-propertize functionality implemented in php-mode really is a performance killer (and in exchange for relatively slight benefits). For anyone who finds performance unacceptable, we can suppress this functionality completely via (setq-local syntax-propertize-function nil)
(remove-hook 'syntax-propertize-extend-region-functions
#'php-syntax-propertize-extend-region :local) Otherwise we can, at minimum, avoid some unnecessary inefficiency in modified lisp/php-mode.el
@@ -1042,13 +1042,16 @@ php-syntax-propertize-extend-region
(let ((maybe (point)))
(when (and (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
(> (point) start))
- (setq new-start maybe))))
- (goto-char end)
- (when (re-search-backward php-heredoc-start-re nil t)
- (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
+ (setq new-start maybe)
(when (> (point) end)
- (setq new-end (point)))
- (setq new-end (point-max))))
+ (setq new-end (point))))))
+ (unless new-end
+ (goto-char end)
+ (when (re-search-backward php-heredoc-start-re start t)
+ (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
+ (when (> (point) end)
+ (setq new-end (point)))
+ (setq new-end (point-max)))))
(when (or new-start new-end)
(cons (or new-start start) (or new-end end))))
;; Cleanup Experimentally, though, it's really the custom This may or may not be on account of the region which is processed regularly being "most of the buffer" in my tests. (...Some seemingly-incorrect conclusions deleted at this point...) |
I'd reached some wrong conclusions after some apparently-bad testing, so I've deleted part of the previous comment. For the moment I'm suppressing the custom propertization entirely as my workaround. |
I also note that
Following that up, I discovered that |
@phil-s For reference, how large are the files you are having trouble with? Asking for selfish reasons, I need benchmark material for my package ;) |
The file that caused me to start debugging yesterday is ~9,500 lines (file size is 385Kb). I do seem to have a compounding problem, as re-testing with a fresh config and just php-mode I'm seeing performance which is significantly better. Still not great in that file, but definitely better than my standard config. I didn't pick up on obvious other culprits from the profiler, though, so I may need to bisect to try to figure out the difference. (Edit: It might not be one thing, mind -- plenty of things have reason to call |
I see. Is it a template with a lot of HTML/text content, or mostly PHP code? |
Entirely PHP code. I'm glad I don't have a 10,000 line template file! My latest discovery is that I don't immediately suffer the same issue when I edit the file in a fresh Emacs instance using the exact same config which did have issues. This is frustrating, as it means I don't know how to trigger the problem. This also rings a bell, though -- I realise that I've experienced this same "starts out fine but gets bad later" issue in the past. I don't know whether it's to do with php-mode, or something in CC Mode land, or something else entirely. |
I just noticed that this topic was revived 3 weeks ago. It seems that calling Both issues seem to be affected by the internal state of |
Every keystroke results in a delay of a few seconds in large files (2000+ lines) making the plugin unusable.
Here's a profile trace:
Let me know how I can debug more!
The text was updated successfully, but these errors were encountered: