Can I put validation in a separate process in document cycle, so it won't block other features like autocompletion? #1829
-
When a single program becomes longer, validation will take a long time. And because validation is in document cycle, every time after document changed, documentValidator will run again. It will cause a serious performance issue. Users need to wait for seconds to see highlights and then the autocompletion items pop up. I am wondering can I put documentValidator in a separate process with low priority, so it won't block other features like autocompletion. Currently all the features need to wait until the end of validation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @durianwaffle, I believe the documentation is a bit outdated, and the information presented there is no longer accurate as of #1334 (v3.0.0). However, nevertheless, running a validation is blocking the event loop, and therefore any operation triggered during a particularly expensive validation can potentially need to wait until the validation is done. It is currently not possible to move validations to a separate process/worker thread due to the AST being very difficult to move across threads. This is essentially a limitation of the JS runtime. However, you can register different kinds of validation checks, see #1094. The API for that is unfortunately not well documented on our website and you will need to dig through our code to make this work in your language server. Note that the best recommendation is to make validation fast independent of the size of your program. This can usually be accomplished by aggressively caching information. This way, we are able to deal with workspaces in the 100.000+ LoC range with Langium without too much issues. |
Beta Was this translation helpful? Give feedback.
Hey @durianwaffle,
I believe the documentation is a bit outdated, and the information presented there is no longer accurate as of #1334 (v3.0.0). However, nevertheless, running a validation is blocking the event loop, and therefore any operation triggered during a particularly expensive validation can potentially need to wait until the validation is done.
It is currently not possible to move validations to a separate process/worker thread due to the AST being very difficult to move across threads. This is essentially a limitation of the JS runtime. However, you can register different kinds of validation checks, see #1094. The API for that is unfortunately not well documented on our websit…