This benchmark tests the Lua Language Server with the Visual Studio Code extension client against a real project that contains 1500 Lua files with a total size of 20MB.
The CPU used is an i7-9700K. The project files are located on a HDD and the server is on an SSD.
After many tests, the loading of the 20MB workspace takes about 10 seconds, meaning the loading speed is ~2MB/s.
Operation | Time Elapsed |
---|---|
Initialize the server, shake hands with the client, read the configuration | 0.5s |
Scan files in workspace and find all Lua file paths | 0.25s |
Start loading workspace and load Lua into memory | 1.5s |
Convert Lua into abstract syntax trees | 6.5s |
Collect information such as global variables | 1s |
Other | 1s |
Because the test was repeated multiple times, the OS cached some of the operations, so the above performance will be better than the actual performance.
In actuality, step 2 and 3 are merged, which can save about 0.5 sec.
According to the test, the most time-consuming part is compiling Lua files into abtract syntax trees. This time is matching expectations, so there may be no room for improvement.
Step 2 is affected by the total number of files in your workspace (including non Lua files).
The best way to improve startup times is to exclude unnecessary files and directories and to not load unnecessary libraries.