Skip to content
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

Process indicator as part of the lighter #3

Closed
minad opened this issue Mar 10, 2023 · 10 comments
Closed

Process indicator as part of the lighter #3

minad opened this issue Mar 10, 2023 · 10 comments

Comments

@minad
Copy link

minad commented Mar 10, 2023

Since we've got this lighter, would it make sense to add a process indicator there too, which tells if jit-spell is active or not? The indicator should be implemented such that it doesn't introduce movement of the mode line or flickering. See for example the indicator in consult-ripgrep which switches from : to * and back, such that the prompt doesn't move.

@astoff
Copy link
Owner

astoff commented Mar 10, 2023

Ah, cool idea. That one I agree will require some caching.

@astoff
Copy link
Owner

astoff commented Mar 17, 2023

I've experimented with this, but at least in normal circumstances the busy state is so short that it just causes a little flicker in the mode line. Only if I set the wrong language in order to get lots of misspellings I see some fun stuff going on. So it looks like this is not a practical feature to provide.

@minad
Copy link
Author

minad commented Mar 17, 2023

Did you try stealth mode?

@astoff
Copy link
Owner

astoff commented Mar 18, 2023

I've created a branch with the mode line counter: https://github.com/astoff/jit-spell/tree/modeline-counter. I maintain my impression this is not a useful thing for the user, but it's interesting for debugging.

I noticed that without stealth mode, jit-lock does what you expect: fontify the area near the window and then stop. On the other hand, enabling stealth mode causes even a 1 character change in a comment to trigger many checks. I suppose you're getting the entire buffer refontified eventually.

@minad
Copy link
Author

minad commented Mar 18, 2023

I noticed that without stealth mode, jit-lock does what you expect: fontify the area near the window and then stop.

Maybe I should just give up on stealth mode. I believe it is nice for font locking only. But still, I think #9 should be fixed. jit-spell has an efficiency problem, which I find hard to justify for a mode which I turn on everywhere.

@astoff
Copy link
Owner

astoff commented Mar 18, 2023

Out of curiosity, why did you turn stealth mode on in the first place?

@minad
Copy link
Author

minad commented Mar 18, 2023

Out of curiosity, why did you turn stealth mode on in the first place?

I've seen it recommended somewhere as a performance optimization (maybe Doom Emacs, could be just cargo culting). So far I never observed bad side effects of it. But maybe it is a useless optimization, since I find it also hard to observe positive effects. :-P

But even if I disable stealth locking, jit-spell is still loading my system too heavily. Aspell takes around 3% and Emacs takes 90%. Without jit-spell this does not happen.

@astoff
Copy link
Owner

astoff commented Mar 18, 2023

Can you reproduce on emacs -Q? I have no tweaks whatsoever to GC, pipe buffer size, etc. I'm not even using native compilation. When I see high CPU usage, it's on the spellchecker side.

@minad
Copy link
Author

minad commented Mar 18, 2023

Yes, I see the high load of Emacs with the following snippet starting from emacs -Q. It suffices to open a file like simple.el or embark.el. Or go to an open buffer of simple.el and turn jit-spell-mode off and on again. I have Emacs open and top next to it. As soon as I toggle jit-spell-mode, the load produced by Emacs increases dramatically.

(package-initialize)

(add-hook 'prog-mode-hook 'jit-spell-mode)

;; Causes high load until the whole buffer is fontified.
(setq jit-lock-stealth-time 0.01 ;; aggressive, not my actual setting
      jit-lock-stealth-nice 0.01 ;; aggressive, not my actual setting
      jit-lock-stealth-load 100
      jit-lock-chunk-size 3000)

;; Reduce load of aspell ~1%. Emacs is high > 90%.
(setq ispell-extra-args '("--sug-mode=ultra"))

;; Doesn't seem to make a difference.
;; (setq read-process-output-max (* 64 1024))

EDIT: I can reproduce this pretty reliably if I open org.el and toggle jit-spell-mode. I use overly aggressive setting in the recipe, in comparison to my actual configuration. I notice that both Emacs and Xorg process load go up. This may be specific to my installation, however it supports the hypothesis that jit-spell causes many redisplays while it is processing the aspell output.

(package-initialize)

;; Causes high load until the whole buffer is fontified.
;; All of the settings are overly aggressive.
(setq jit-lock-stealth-time 0.01
      jit-lock-stealth-nice 0.01
      jit-lock-stealth-load 1000
      jit-lock-chunk-size 10000)

;; Reduce load of aspell ~1%. Emacs is high > 90%.
(setq ispell-extra-args '("--sug-mode=ultra"))

@astoff
Copy link
Owner

astoff commented Mar 18, 2023

On a tangent, the mode line seems to ignore the text properties returned from an (:eval ...) construct. How do I get around this?

@minad minad closed this as completed Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants