rescript-vscode
rescript-vscode copied to clipboard
Design: reduce latency by saving initial state
Every time any editor command is invoked, the analysis starts from scratch. Find and read bsconfig.json
, scan project files, etc.
Then executing the actual command is typically little work (exception: command to find all the references).
See for example:
https://github.com/rescript-lang/rescript-vscode/blob/master/analysis/tests/src/expected/Debug.res.txt
There's an opportunity for reducing latency by caching the initial state of the project before executing the specific command.
However, even though technically this is a clear opportunity for speedup, latency has in practice not been an issue in existing projects. So this note is just about some design ideas, but there's no action plan at the moment, as there is no need.
Anyhow, one could save the state after project initialisation, in a special marshalled file. And if that file exists, one can quickly read that marshalled file. Care is required to consider all the inputs to that file (for example, if bsconfig.json
or any other input changes). Plus, one needs to check that if a .cmt
on disk has changed (probably via timestamp), that the new version is loaded. Such a mechanism was there until recently, so it's about checking that it still works.
Finally, there's the question of when to update the file with the marshalled state on disk.