SublimeText / TrailingSpaces

Highlight trailing spaces and delete them in a flash.
MIT License
896 stars 94 forks source link

High CPU usage when this plugin is enabled #144

Closed xhpohanka closed 4 years ago

xhpohanka commented 4 years ago

I see a high CPU usage (around 15-20%) with TrailingSpaces enabled, even when sublime is on background. My operating system is Arch Linux, sublime-text-dev package...

rchl commented 4 years ago

What kind of CPU do you have? Does the problem persist after ST restart? Does it happen right away after restart or after using ST for some time?

xhpohanka commented 4 years ago

What kind of CPU do you have?

Intel(R) Core(TM) i7-8565U CPU

Does the problem persist after ST restart?

Yes

Does it happen right away after restart or after using ST for some time?

On my setup it is perfectly reproducible, the CPU is stressed whole time since starting ST. It goes back to normal when I add TrailingSpaces into ignored packages...

rchl commented 4 years ago

There is a update_interval setting (by default set to 250ms) that you can try changing to something much higher just to confirm that it's that causing the issue.

xhpohanka commented 4 years ago

It really seems that it is related. When setting update_interval to 25000 I have a 20% peak on CPU usage each 25 seconds :)

rchl commented 4 years ago

I can see something like this with TS enabled: Screenshot 2020-05-18 at 23 16 11

So CPU usage jumps up and then slowly gets lower until it jumps up again. And that's over many seconds, with a default 250ms interval. It seems weird to me.

xhpohanka commented 4 years ago

I see similar behavior as you - CPU usage peaks and then it is slowly decreasing, then peaks again. When there is no file opened CPU is low as well as with file with no syntax enabled.

TrailingSpaces settings is blank. I also tried to find if there is any interaction with other packages but it does not seem so.

rchl commented 4 years ago

FYI: Created ST issue for it https://github.com/sublimehq/sublime_text/issues/3353

nho-sh commented 4 years ago

I was also experiencing a continuous high CPU load in ST3. After trying a lot of things, I finally narrowed it down to this plugin. Setting a high update_interval (10s) seems to work, thanks

rchl commented 4 years ago

This is fixed in the latest dev builds of ST4 (see https://github.com/sublimehq/sublime_text/issues/3353) so I'm closing this issue also.

Unfortunately, it's not likely that ST3 will receive the same fix.

garymoon commented 4 years ago

Just to be sure I understand, there's a bug in ST causing this, it's been fixed in the latest dev release, but the same fix won't be applied to the current stable release, and now the bug is closed?

rchl commented 4 years ago

Yes. The solution for ST3 users is to increase the update_interval value to minimize the issue.

garymoon commented 4 years ago

I guess I have to appreciate the honesty? :man_shrugging: Thanks @rchl.

dcanuhe commented 3 years ago

@garymoon: reverting to e24719053fe6960a327591d2c48ccbd49684500d fixed this issue for me. It's not ideal, but it works.