MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.72k stars 254 forks source link

unnecessary re-indexing when trackDepenency is 2 #927

Open JohnC32 opened 1 year ago

JohnC32 commented 1 year ago

We have a large code base and it takes hours to index. Therefore, we index the code base using ccls in cron at night. We are using the btrfs file system which means we can create instant snapshots (clones). So our workflow is

  1. cron at night: run ccls into a "latest" area and store the index within the "lastest" directory
  2. workday: clone the latest area into a "working" area, which means we copied the pre-generated index
  3. Using emacs as a front end, we work in our "working" area. We start LSP / CCLS using the pathMappings option to reuse the copied pre-generated index

We've noticed that if trackDependency is 0 we see in the Emacs *ccls::stderr* thousands of "I load cache for" messages and ccls starts up quickly in a few minutes.

However, if we set trackDependency is 2, we see in the Emacs *ccls::stderr* thousands of "I load cache for" and "I store index for" messages. In this case ccls starts up slowly taking hours. I assume the "I store index for" messages are CCLS re-indexing the file that is already index.

Why does changing the value of trackDependency not reuse the already computed index?

You should be able to reproduce this by

  1. pre-indexing say ccls itself in a "latest" directory
  2. cloning or cp -r the "latest" directory to a "working" directory
  3. Use emacs or other editor to start ccls with the different values of trackDependency and the necessary pathMappings.

System information