hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
295 stars 57 forks source link

Save cached file index on disk #39

Open MagBad opened 6 years ago

MagBad commented 6 years ago

I have a feature request for a persistent save of the file index on disk. From my work with cquery at work I appreciate its feature for storing the file index on a specified directory on exit. This enabled for 'faster' start up times of the server for larger projects. Currently I'm doing just some small projects in Fortran as a hobby, but I can imagine that with a large code base the startup of the server can take a significantly amount of time. cquery-initialization-options stores a .json file for each indexed file for inspection or in a more binary format for faster startup times. The first approach seem to be a nice feature for debugging purposes as well from my point of view.

hansec commented 6 years ago

At the moment I don't think this is a big issue. I work with several large projects (over 50k lines or Fortran each) and the longest any of them takes to launch and initialize is about 1 second on my 2013 Macbook Pro. In many editors (Atom, VSCode, etc.) this is overshadowed by the startup time of the editor so its not even noticeable. Even on a lightweight editor (emacs or vim) I think a few seconds is acceptable for initialization the server.

If you run into any projects where the initialization time is an issue let me know. However, at this point I think any startup performance issues can probably be solved by improving the parser or other components as I haven't done a lot of optimization yet.

I do plan to implement a way to save the index to disk at some point to support external libraries in projects. I will take a look at doing serialization of the internal project representation at the same time.

MagBad commented 6 years ago

Ah okay, it's been a while since I had access to such a big project in Fortran. A issue regarding cquery doing may be that C++ is a terrible language to parse and hence it takes a while.

Speaking of a plan do you have a sort of TODO list/Roadmap of features you want to implement in the future? Maybe I can help.

MaskRay commented 6 years ago

I have a different/simplified cache implementation in https://github.com/MaskRay/ccls/blob/master/src/pipeline.cc

It provides some interesting yet niche initialization options:

I'd be very interested to know the scale of the project you have accessed.

loc llvm => 1175817 C++ Code. It takes 1 hour to index all compile_commands.json entries on my laptop but ~20 seconds to load the cache.