Sublime Forum

Every update my macbook explodes!

#1

I just updated and yet again SublimeText thinks it’s okay to hog CPU for 15+ minutes…

I do not use that many plugins, and I need all of them– and I just don’t have the time to go through all of them, disabling, to see whiiich one might be the hogger.

From an earlier research in this I remember ST3 needs to do some indexing; but of what? Is this really necessary? Why does it need to happen after every update+restart of the machine? We are not talking about After Effects here; this is just a text editor, isn’t it? Not even an IDE.

Please forgive my frustration; but I just feel like my maxed out MacBook Pro 15’’ late 2013 on latest macOS High Sierra should be able to handle ST3 without trying to take off to Mars–

Can you explain what is happening here? Why are there 7 sublime tasks hogging up that much CPU? How’s that even possible; I’m just a web developer, but still skilled enough to see that there is my 500+% of something is nonsense :smiley:

[EDIT]
I took some notes on my iPad, so my Macbook was just sitting there– and suddenly the fan kicks in again; another 5 ST3 tasks sucking up CPU like apple juice. Whaaaat?

0 Likes

#2

Try using the “Sample Process” action in Activity Monitor, it might give you a hint of what’s happening.

0 Likes

#3

ST indexes all files in the sidebar. ST opens each file to collect all symbols (functions, …). The resulting database is used for the Goto Anything, Goto Definition Popup, Goto Reference Popup, … .

The amount of time needed to do so depends on the complexity of your open project (number of files, type of files). If a nodejs project is open with 10.000s of javascript files in the node_modules folders it may take a while to parse each of them.

You can disable indexing via "index_files": false if you don’t need the Goto Definition Popup or Goto Reference Popup stuff. I do so as I use LSP for IntelliSense like features and reindexing during syntax definition development is extremely annoying.

ST rebuilds the index …

  1. everytime a syntax definition was changed, which might cause new symbols to be defined by the update.
  2. after startup as the files in your project might have been changed while ST was not running.

ST tries to guess the number of CPU cores to use for indexing. You can set a fixed number of processes being spawned by setting "index_workers": 2

2 Likes

#4

Thank you very, very much for this detailed explanation, @deathaxe!

I don’t import node_modules folders into ST3, but sometimes the whole wordpress folder. So that could be where many files lay.

If I understand you correctly, with index_files disabled I can still use Go To Anything – meaning jumping between files with fuzzy search, right? Because that’s the only Go To function I use (but this one I use veeeery often)

Would you recommend fixing the index_workers, or is it better to let ST do its thing as quickly as possible, so it’s over sooner? :smiley:

Could you go a bit more in depth with your LSP/IntelliSense setup? What problem are you solving here? Is this a substitute for Goto Definition and Goto Reference? After a quick google, this sounds interesting.

Thanks again!

Louis

0 Likes

#5

If I understand you correctly, with index_files disabled I can still use Go To Anything – meaning jumping between files with fuzzy search, right?

Yes.

Would you recommend fixing the index_workers , or is it better to let ST do its thing as quickly as possible, so it’s over sooner?

Don’t know about the heuristics ST uses to decide how many cores to use. I am on Windows 10 with a Core i5 and ST decided to use only one process to index. Your screenshot looks like all cores being used. If ST can’t guess the correct value for some reason, I’d adjust it manually. I set index_workers to 3 to keep one core idle for other tasks and prevent programs from slowing down too much.

Could you go a bit more in depth with your LSP/IntelliSense setup?

ST’s index is currently limited to the Goto Definition and Goto Reference stuff, but without any filter for appropriate languages. Hovering a symbol in JS may return results in a C++ module - sometimes more garbish than useful stuff.

The information collected by the indexer are not available for auto completions. The most important feature for efficient developement is to get proper context sensitive suggestions about what might be the next best input to do. No one can remember all the available variables or class members of modern frameworks.

ST’s static contextless completions can’t fulfill that requirement in any way. They work well for simple stuff only, but don’t help much with sophisticated frameworks especially if you are not too familiar with them.

I mainly do python development and try to find my entry to Powershell. I found language-servers for both of them. They have a much better understanding about the code structure than ST and can therefore provide context sensitive completions. OK, they are not always corret as well, quality depends heavily on the language-server implementation and the protocol itself may have some edge cases, but in the end the results are much more IDE-like and helpful, than any static completions.

Python: https://pypi.org/project/python-language-server/
Powershell: https://github.com/PowerShell/PowerShellEditorServices

There are more servers for more syntaxes as well. The technology is young and may need to mature. Not sure if the HTTP/JSON-RPC approach to communicate between editor/server is the best one, but in the end such a “common” approach is the only way to keep the “editors logic” simple and let the “syntax/language specialists” create the backends.

Most syntaxes are too sophisticated for ST to properly parse all the required details to build a suitable database for code IntelliSense features. Hence this task should be left to the language-server devs. ST won’t be able to compete with dozens of them at a time.

The currently available solution to make use of the language-server-protocol is the LSP package.

0 Likes