Sublime Forum

High CPU and RAM Usage On Startup While Not Indexing

#1

I looked at several other topics on high CPU usage, but none of them seemed to fit what I am seeing.

I am running Build 3177 on Ubuntu 18.04 with no extra plugins installed.

Opening Sublime Text will cause the CPU to vary from 30-200% or so for an hour upon opening the project I have setup. During this time, the overall system use is very sluggish. The RAM usage will eventually get up to around 3GB. After it finally calms down on CPU usage, the RAM usage stays at the high level. The CPU usage will stay low, and the system will behave normally after that as long as I do not close and reopen it. A close and reopen starts the process over again. This all seems to be a bit excessive for a text editor both in processor and RAM usage.

It is not indexing while the CPU load is high as the Indexing status says idle for the whole time.

There are some folders in the project that have a large number of subfolders and files in them. I have placed them into the binary_file_patterns to prevent them from being indexed (as mentioned in a different post), and based on the Idle indexing status, I believe that Sublime Text is not indexing them. I do not need those folders to be indexed, I just want to be able to get to the source files from the sidebar. (There are other folders that I would definitely like to be indexed though).

Just to make sure the problem is not indexing related at all, I also turned indexing completely off and restarted, and the problem was still there.

Looking in the console window while this is going on, the folders that are not getting indexed are getting scanned (lots of symbolic link messages (i.e. “scan: … has been seen before, skipping (using inode) …” type messages.

Is this always going to be the case with Sublime Text where if I want a folder in my project that has lots of other files and subfolders that are not ever going to be indexed, then when I open the program it will make my PC unresponsive for an hour while it scans the non-indexed folders?

Do I need to exclude folders like that from the sidebar if I do not want an hour or so of bad system performance every time I open it? That would be exceptionally annoying to have to use a separate file browser window and drag and drop those files into Sublime Text since it is just a tree hierarchy.

If I let the folder in question be indexed by Sublime Text, after it finished, would restarting Sublime Text not have the problem since the folder is in the index, or would it just take longer in the indexing portion? Would that at least get rid of the 3GB of RAM usage?

Thanks,

Rich

0 Likes

#2

You should try this out on the latest dev build (3193). If I’m not mistaken, there have been multiple optimizations done to the indexer & related processes which may alleviate your issues.

Also, build 3177 isn’t an official build & may have unrelated issues:

0 Likes

#3

There are two parts of Sublime Text that access files on your filesystem. There is the catalog and the indexer.

The catalog is the list of every file and folder contained within the folders you’ve added to the sidebar. This powers Goto Anything. We have an in-memory representation of every file, with it’s path and basic information about it (if it is a “binary” file, thus excluded from indexing).

The indexer uses the catalog and opens each file from it, one at a time, syntax highlights the file and then extracts any function and class names and stores it in the “index”. The index powers Goto Definition and Goto References.

Disabling indexing skips the second part, but there is no way to prevent cataloging a folder, other than excluding it or not opening it in the first place.

I’ve seen some reports of people who see issues where Sublime Text’s IO thread is running for a very long time building a catalog. Typically this happens if they are adding the root folder of their hard drive, or possibly their entire home dir to Sublime Text, and Sublime Text it building a catalog with millions of files or more. Beyond just adding all of those files to the catalog, Sublime Text has to listen for filesystem events. If you have added your entire home dir, then any time any program writes a file in your homedir, Sublime Text will be notified and will check to see what has changed.

The 3GB of ram usage would indicate to me something is wrong. Sublime Text typically will use about 100mb when first opened. If every single syntax definition is loaded, that can jump up to around 200mb (if I recall correctly). Obviously Sublime Text will keep a copy of any open files in memory, along with some overhead related to syntax highlighting, but 3GB sounds way too high. Currently with Sublime Text open, the Sublime Text codebase folder added to the sidebar, and indexing enabled I am using around 200MB of ram.

If you have opened a huge dir that is really more than a single software project, then I’d recommend checking out the projects functionality. It is pretty painless to create a new project and add the folders that are relevant. Then when you want to switch you use the Switch Project window and you can move between projects in a fraction of a second.

4 Likes

#4

Thanks for the quick replies.

First off, I had a typo as it was Build 3176 not 3177 that I was running. I was not intentionally running some weird build. So, I hope build 3176 make more sense.

Second, wbond’s answer confirmed that what I am seeing will persist as long as have a large folder in my project that is not indexed. I had assumed that if I removed it from indexing, then it would just be in the sidebar waiting for me to select it before doing any processing of it at all (i.e. build the tree as I drilled down into it). So, I will just use a different method to deal with that folder.

Thanks again.

0 Likes