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

Freeze on big buffers #16

Closed
nico202 opened this issue Jan 15, 2018 · 6 comments
Closed

Freeze on big buffers #16

nico202 opened this issue Jan 15, 2018 · 6 comments

Comments

@nico202
Copy link

nico202 commented Jan 15, 2018

Hi, thanks for this. It's working good, but I encountered a problem with big buffers.

I opened a 110kb csv with global-highlight-thing-mode on and my emacs just stopped working (not responding even to C-g).

Is it possible to limit the search to visible part, or to cursor +/- X lines? Else a timeout that tells it might not take more than X seconds or something.

Thanks, Nicolò

@fgeller
Copy link
Owner

fgeller commented Jan 29, 2018

Hi @nico202 - sorry for the delay. Would you mind sharing the csv or provide a sample that I could test this with and maybe some more details about your setup? I assume the issue goes away when you disable global-highlight-thing-mode? Have you tried disabling font-locking? I often open files that have several megabytes without any issues (but I have font-locking generally disabled and run emacs only in a terminal).

It'd be difficult to limit the highlighting in such a way as you describe as this lib uses very basic Emacs functionality. That functionality is usually rock-solid and I'm not too keen on implementing my own versions ;) If you're interested, at the core it uses a function called hi-lock-face-buffer - try C-h f or M-x apropos to find its documentation.

@nico202
Copy link
Author

nico202 commented Jan 29, 2018

Hi, thanks for your reply.

I attached the file (txt because of github). C-n on the first cell (0) takes 1 second, I think it depends on the fact that there are a lot. disabling font lock (font-lock-mode) does not help

example.txt

@fgeller
Copy link
Owner

fgeller commented Jan 29, 2018

Thanks for the quick response!

I do get some delay if move around constantly, with some delays to trigger the highlighting and it's probably as you say, the fact that there's tons to match, e.g. a lot of 0. Not sure what we could do to improve. Two things come to mind:

  • Could you try increasing the delay between highlights? e.g.
(setq highlight-thing-delay-seconds 1)
  • Could you maybe try using a different thing to highlight. I have it set to symbol and that seems to work ok for me, sth like region would actually delay highlighting until you mark something:
(setq highlight-thing-what-thing 'region)

@nico202
Copy link
Author

nico202 commented Jan 29, 2018

  • (setq highlight-thing-delay-seconds 1): faster of file open, same as before as soon as it starts highlighting
  • (setq highlight-thing-what-thing 'region): as soon as i mark a point freezes as before. I forgot to unmark the region and emacs became completely unresponsive even to C-g and I had to kill it..

edit: I don't have right now the time to read hi-lock-face-buffer doc, any way to limit the match results?

@troshko111
Copy link

Horrible CPU spikes and total freezes repro for me as well, actually just setting the mode to region (IMO the most sensible one) and setting a mark anywhere results in a complete freeze and overall system CPU utilization shooting to the moon (have to be fast with that xkill).

Sadly this is a huge bummer and makes the extension pretty much unusable for my purpose (I'm trying to achieve the same what VS Code does - highlight selected region occurrences after a delay, super useful for say comparing regions for equality and faster than doing M-s h r)

Other "thing" modes seem to work fine but region is just so much more useful

@fgeller
Copy link
Owner

fgeller commented Dec 29, 2018

hi all - just pushed some commits that allow you to restrict the region to highlight in to several lines surrounding point. i added a brief note to the readme, but here's what i did that enabled me to move around in the file linked above without any delay:

(setq highlight-thing-limit-to-region-in-large-buffers-p t
        highlight-thing-narrow-region-lines 15
        highlight-thing-large-buffer-limit 5000)

this would highlight a given thing only if it is 15 lines above or below point when in a buffer that has more than 5000 "characters". no such restriction would apply to buffers with less characters.

let me know if you run into any issues, optimistically closing this issue for now though :)

@fgeller fgeller closed this as completed Dec 29, 2018
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

3 participants