-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option for cache management (#319)
* Fix syntax highlight Extract an explicit function expression to a variable to fix broken syntax highlight. For example add an `-spec` line or `-define` after function `index_of` and those will not be syntax highlighted. * Fix a log message * Use default shutdown time for gen_lsp_server Erlang/OTP `supervisor` documentation says: [1] > It is also allowed to set it to `infinity`, if the child process is a > worker. > > Warning > > Be careful when setting the shutdown time to `infinity` when the child > process is a worker. Because, in this situation, the termination of > the supervision tree depends on the child process, it must be > implemented in a safe way and its cleanup procedure must always > return. Therefore, the shutdown time of `gen_lsp_server` is changed from `infinity` to default value, that is `5000` milliseconds for worker processes. Additionally, a sketch of the application supervision tree is added to module header of `vscode_lsp_app` for easier understanding. The `-behaviour` attributes are added to the corresponding modules, also for easier understanding. [1] https://www.erlang.org/doc/man/supervisor.html * Add option for cache management Add a configuration setting to change the storage mode for large cache tables (mainly used for code navigation). Available modes: - `memory` (default, original): use ETS tables - `compressed memory`: use ETS tables with `compressed` flag turned on. - `file`: use DETS tables saved into temporary files. Why is this configuration option needed? In shared environment, where many instances of `vscode_erlang` run in the same time on large code bases, noticeable amount of memory can be consumed by this extension that eventually can exhaust all the memory. Notes for `compressed memory`: Some simple tests, done in the above explained scenario, showed memory consumption dropped by 50% when `compressed memory` is configured. Notes for `file`: As multiple extension instances can run in the same time on the same host, even in the same workspace, we cannot use static filenames, nor workspace specific filenames to create DETS tables. The only option is to use unique filenames, like temporary files. Of course, it has a drawback, temporary files must be deleted on exit otherwise those will consume a lot of disk space after a while. If the extension is shut down normally, it's not a problem, the extension deletes it's own cache. However, if some extension is terminated brutally, the cache files left on the disk. Hence, an automatic mechanism is hooked to the points when configuration is received from Visual Studio Code, and to normal shutdown, to look for cache directories created by yet not running extension, and delete them. Reusing old cache files is theoretically possible if only one extension instance run in a workspace, VSCode is closed and reopened, then the new extension instance could continue where the previous one stopped. But, as multiple extension instances can run in the same workspace, it can easily go wrong. Therefore it is simpler to use instance specific DETS files, just like instance specific ETS tables. --------- Co-authored-by: Kornel Horvath <kornel.horvath.p.i@gmail.com>
- Loading branch information
Showing
19 changed files
with
357 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.