Search code examples
sublimetext3sublimetext

Sublime Text indexing taking longer than usual


Sublime Text 3 has been indexing files for the past couple days. Usually this process takes 20-30 minutes. Notice that the numerator (in the screenshot below) is not changing, although the denominator is.

Questions:

  • What is the indexing process?
  • Why is it taking so long?

enter image description here


Solution

  • There is a lot of information about Sublime Text's indexing in the official documentation. Here's the crucial quote but you should read the linked page.

    Sublime Text includes an indexing engine that scans all of the files and folders in a window/project and uses that information to provide the ability to jump to definitions.

    In order to do this Sublime Text must monitor file writes within the files of project folders so that it can update its internal catalog or index. There may be several windows open, each with its own project, and each project may contain several folders each of which may in turn contain an entire folder tree of files.

    If you don't want to use this feature indexing can be turned off by setting index_files to false in your Preferences.sublime-settings file.

    The 2 most common reasons why someone's indexing is taking a long time are these.

    • Adding a home folder or the root of a file system as a project folder - a possibly huge number of files will need to be indexed and then monitored. Of course the same problem would occur if any folder is added that has a large number of files within its tree. On my desktop computer adding my Programming folder would cause major indexing problems because that folder is the head of a tree containing 75,000 files.

    • Adding a network folder, i.e. a folder that is not on a local file system but exists on a local or wide area network. Indexing and monitoring files/folders over a network will be massively slower than on a local SSD or HDD. In some development circumstances it is quite easy to do this inadvertently, e.g. a folder is added to a project and later a network drive is mounted in one of its subfolders.

    Project folders in Sublime Text are intended to be the folders required for a specific development project. They are not intended to be used for the indexing of 1000s of files. Of the programming projects I have, the largest has 3 project folders containing a couple of dozen subfolders and perhaps (at most) 100 files.

    There have been some versions of Sublime Text that have introduced indexing problems. This is unlikely to be the cause of your troubles because your problem has started recently and there have been no new versions of Sublime Text 3 released in more than a year.

    You may be able to diagnose why your indexing is taking so long by looking at its status rather than viewing the jobs in the console as you've posted. The crucial difference is that the indexing status specifies folder names, as shown below, so you may be able to see where the problem lies. e.g.

    ...snip...
    index "ProjectFolderName" collated in 0.00s from 19 files
    index "ProjectFolderName" is using 12304 bytes for 222 symbols across 323 locations
    indexing [job 396]: spawning 1 workers to process 1 / 1 files
    indexing [job 396]: indexed 1 files
    ...snip...
    

    You can open the indexing status window from the Sublime Text menu using Help --> Indexing Status... or by selecting Indexing Status in the Command Palette.