-
-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ajv 8.6.0 makes VSCode IntelliSense extremely slow #1667
Comments
Ajv v8 uses somewhat more complex JSONSchemaType type definition than v7, it enables union support and better error reporting. The compilation time in 5-15 seconds for such a simple example is still difficult to explain - it might be related to how much memory, what CPU you have, so it's ultimately the problem of either TS or VSCode performance. The file with the type definition is only 180 lines of code - it is a complex type, but it should still be compiled in under 1 sec time. Ultimately, the resource requirements for "compiling as you type" would be higher than just for editing and you need to either free-up memory and/or CPU, re-configure (or change) the editor so it is impacting the UI less. I do not have such a noticeable performance degradation by the way, with substantially larger schemas than in your video. Out of curiosity, what is the compilation time when you just compile with tsc? What's the system configuration (memory/CPU/OS)? In any case, this is not a problem that can or should be addressed in Ajv - the compilation performance is something to be addressed in TS and or VSCode. |
Also, why do you require ajv TS code? You absolutely should require compiled ajv code with |
I have a large project and compilation time takes ~10 sec
I tried PhpStorm IDE and the same behaviour. Seems like some problem with TS.
I use this example to create a validator based on a type. And after some tests I noticed if And looks like there is the same problem. Anyway, thanks a lot! |
What I meant is that from looking at the video you require ajv from .ts file, not from the compiled JS as in the example… Am I missing something? That might be the reason for slow compilation… |
In ajv.ts file
It is like in my existing project where in my ajv.ts file also exists some utils function like middleware wrappers for expressjs and other tools. BTW, I attached the project's example :) |
Got it… This is still strange as I don’t have such a long compilation time… |
Please don’t delete the sample project - I will experiment with it later. |
Could you tell what IDE do you use?
No problem! |
VSCode |
Update: I have done this and it helped. VSCode IntelliSense works properly. It is really problem with TS |
Ah - interesting... |
I don't know how VSCode works with other languages but I tried PHPStorm and there is the same problem with the current issue because PHPStorm uses the same typescript engine for code completing :) |
@erikbrinkman - have a look at microsoft/TypeScript#44851 and https://gist.github.com/armanio123/95a33f9ad3286a7d78590eb11af293c4 - this is a suggestion on how to workaround the performance degradation caused by this change: microsoft/TypeScript#30639 Could we maybe use it to improve performance? Thank you! |
Yeah, seems pretty simple to split it up. I'll have to figure out how to benchmark... |
@erikbrinkman thanks! I tried your new version but unfortunately the performance still very poor. |
@epoberezkin In light of those two facts, it seems unlikely that changing the type will do anything. Maybe it's worth adding a note somewhere about typescript 4.3, or maybe this issue will be enough. |
Thanks a lot for investigating - I think it’s ok to leave it as is, everybody will migrate relatively soon… |
Closing it now |
It seems like 8.6.0 has some performance issues with the TypeScript server. This could be a possible fix: ajv-validator/ajv#1667
After adding to a project Ajv 8.6.0 and importing it in the project makes InteliSense very slow.
Typing some text and getting suggestions for code completions takes ~5-15 sec.
videoplayback.mp4
Example of project
With Ajv 7.2.4 no problem
The text was updated successfully, but these errors were encountered: