Skip to content

[json] schema Validation/Intellisense very slow when JSON deep and Schema Complex #42679

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

Open
hipstersmoothie opened this issue Jan 31, 2018 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues json JSON support issues
Milestone

Comments

@hipstersmoothie
Copy link

hipstersmoothie commented Jan 31, 2018

In my project we design an API that allows people to define web pages in json using a bunch of nested components. We have schema files for all components and how to combine them. When merged into 1 schema file it becomes around 7000 lines long.

I am noticing a huge slowdown when a file has JSON that is relatively deep.

Here is what it looks like when the depth is still okay
fast

And here is what it looks like when a deep component is defined in the same file
slow

  • VSCode Version: Version 1.20.0-insider
  • OS Version: OSX 10.13.3

Steps to Reproduce:

  1. Set schema for JSON to some large and complex schema
  2. Open up a JSON file that uses the schema
  3. write enough JSON so that you are nested a bunch
  4. try to use intellisense
  • whole editor slows down
  • Intellisense suggestion doesn't pop up until validation is done - even looks like it validates the file a few ways while you sit

Is it possible to just turn off JSON validation and keep the Intellisense? Or just validate on file save? Could we show Intellisense suggestions before validation happens?

Also, when i am editing 2 JSON files the slowness is shared by the two. Even after closing the file that made everything slow, I still have to wait for some validation thing to finish before it realized the file is closed and updates the UI

If needed I can try to reproduce this bug with generic schema files.

What seems to be the issue is when i have a Collection component. This component can hold any other component, including more nested collections. If I nest a bunch of collections the problem presents itself.

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

@vscodebot vscodebot bot added the json JSON support issues label Jan 31, 2018
@alexdima alexdima added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Feb 1, 2018
@aeschli
Copy link
Contributor

aeschli commented Feb 1, 2018

@hipstersmoothie Any chance you can share the schema or a similar example?

@hipstersmoothie
Copy link
Author

@aeschli I will try to get a sharable example going tomorrow!

@hipstersmoothie
Copy link
Author

Sorry for the wait! @aeschli I have made a private repo and shared it with you. https://github.com/hipstersmoothie/schema/invitations

@hipstersmoothie
Copy link
Author

I have also provided a test file which shows the slowness

@aeschli aeschli added this to the Backlog milestone Mar 1, 2018
@aeschli aeschli added the bug Issue identified by VS Code Team member as probable bug label Sep 21, 2018
@aeschli
Copy link
Contributor

aeschli commented Sep 27, 2018

Thanks a lot for the example, and sorry for the wait.
It's an interesting example, and the our schema validation gets to its limits.

Each node can have have multiple alternatives. When testing which alternative to use we test the full object, including children and children's children. Each child type again has many alternatives.

To make this more performant we need to avoid validating children if we see that we are of the wrong type.

@aeschli aeschli changed the title JSON Schema Validation/Intellisense very slow when JSON deep and Schema Complex [json] schema Validation/Intellisense very slow when JSON deep and Schema Complex Oct 8, 2019
@revilowaldow
Copy link

@aeschli is there any chance of progress on this? I don't have the experience to fix it myself but it's very impactful on us working with a similarly complex and recursive schema.

We have to fall back to regularly validating with ajv or similar while writing documents when vscode is no longer suitable.
We've even got 'fast' versions of the schema that don't validate certain parts of the file at all so we can stretch the intellisense further.

I've got an example for you here of the schema; homebrew.json is the base document, entry.json is the part that recurses.
https://github.com/TheGiddyLimit/5etools-utils/blob/master/schema/brew/entry.json
Here's an example of a document that slows to basically non-responsive during editing:
https://github.com/TheGiddyLimit/homebrew/blob/master/book/Darrington%20Press%3B%20Tal'Dorei%20Campaign%20Setting%20Reborn.json

@aeschli
Copy link
Contributor

aeschli commented May 1, 2023

@revilowaldow Sorry, there is currently no time budget for working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues json JSON support issues
Projects
None yet
Development

No branches or pull requests

4 participants