question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

IntelliSense slow down with large json file

See original GitHub issue

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.65.2
  • OS Version: Ubuntu 20.04.4 LTS

IntelliSense slow down when I set value for compilerOptions->jsx option in tsconfig.json file. Without this option (after restart vscode) I get autocomplete suggestion less then 1 second, with compilerOptions->jsx I get suggestion after 3-4 seconds. CPU i5 8 cores, available RAM more than 10GB.

When initializing js/ts language features in progress IntelliSense work fast

Tried in 1.66.0-insider the result is the same

{
	"compilerOptions": {
		...
		"jsx": "react",
		...
	},
	"exclude": [...]
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
gabrittocommented, Oct 18, 2022

Iā€™ve been investigating this issue, and at least for the example large jsons provided here (by @steve-ross and the json files in @ryancwalshā€™s paintcolornerd), it seems what is happening is that weā€™re taking too long to type check the very large array in the json file, because in those cases the kind of type checking/inference we do is quadratic on the size of the array literal. This affects intellisense because, in general, when you open or change something in your file that imports the large json, we have to type check it again, and it takes a while. So thereā€™s a general slowdown on things like completions, updating errors/red squiggles, quickinfo, etc, that rely on having your file type checked.

  • From the checkerā€™s implementation side: This happens because, when we are trying to figure out the type of your json array literal, we start by getting the type of each of the json arrayā€™s elements, and then we try to union them one by one to get the type of the array. But in this process, when we get the type of an arrayā€™s element and try to add it to the union, we first check if that elementā€™s type is already present in the union (more specifically, if itā€™s a subtype of some type already in the union). That process, in the case of this json array literal, turns out to be quadratic in the size of the array.

Iā€™m now going to think about ways in which we could improve this.

1reaction
ryancwalshcommented, Oct 11, 2022

I finally found this issue after days of this problem. Iā€™d been disabling all of my VSC extensions trying to figure out why Intellisense got so slow for a project of mine.

I finally narrowed it down to this one line in a file: import megaColors from '../data/colornerd.json';

The JSON is 3 MB. Having that one line makes Intellisense unusably slow for the whole project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle load time of big JSON for autocomplete on the server ...
Checking the issue it seems that it takes a lot of time to load the 50MB JSON for each request. Loading the data...
Read more >
Editing json file in VS 2019 is laggy and slow
Trying to add variables and it appears to be trying to validate the json constantly while I'm typing leading to long lag times...
Read more >
Speed up ReSharper (and Visual Studio) - JetBrains
The most common causes of performance problems could be eliminated with the ... This will improve the typing experience inside large files.
Read more >
Strongly Typed JSON in TypeScript - DEV Community ā€ ā€
The reason it's a compiler option is because it can slow down the compiler for large data. You might be better off using...
Read more >
Improving VS Code Path Intellisense Performance - Medium
I've been fighting slowdowns in Intellisense plugins (like this) in VS ... you can exclude large folders to reduce the initial load. "files....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found