Skip to content
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

Question: what is the performance impact of implementing this in the typing system? #31

Closed
marcelbeumer opened this issue Jun 5, 2021 · 6 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@marcelbeumer
Copy link

Hi @ThomasAribart, thanks for your awesome work, json-schema-to-ts looks very interesting!

I was wondering though, what performance impact can we expect implementing this in the typing system? A lot of TS logic needs to happen on the fly for inferring the schema TS types, and my worry is that when codebases grow, the TypeScript language server might take a long time to startup, and we'll start feeling in in our editing experience. But maybe it's all super fast and little work compared to all other things TS has to do on a codebase.

I imagine a few use cases where this matters:

  • opening your editor, lang server starts, opening a file that uses a FromSchema type or two from other files
  • opening your editor, lang server starts, opening a file with many/all schema's in your app
  • building your project with tsc

I'm now using a (more complex) build time solution, but if json-schema-to-ts has an insignificant perf impact it would make things easier and more elegant. Curious about your thoughts on this!

@marcelbeumer marcelbeumer changed the title Question: what is performance impact of implementing this in the typing system? Question: what is the performance impact of implementing this in the typing system? Jun 5, 2021
@marcelbeumer
Copy link
Author

marcelbeumer commented Jun 5, 2021

PS: I had some bad experiences with complex typings impacting the editing experience in the past with for example styled-components. Not sure if still the case, but it made editing react code sluggish (in vscode back then), switching to an alternative lib fixed that. With so little control and insight in what's going on with the TS server in the background very complex third-party typings can be a bit scary.

@rattrayalex
Copy link

rattrayalex commented Jul 10, 2021

You may find what you're looking for here: #20

(Perhaps some summary of that discussion could be added to the readme?)

My overall impression is that the perf hit scales with the size of a given json schema – having a lot of schemas shouldn't be too much of an issue, but having really large/complex ones might be.

@ThomasAribart
Copy link
Owner

ThomasAribart commented Jul 13, 2021

Thanks for your answer @rattrayalex

Yes, I've been very busy on other subjects lately, but I'm definitely going to add those points to the README.

@marcelbeumer I've used this lib on a large project with 200+ small/medium schemas (50 to 100 lines). The IDE experience was still very smooth.

  • opening your editor, lang server starts, opening a file that uses a FromSchema type or two from other files => Type infering only takes a few seconds, it is very acceptable, at least on small/medium schemas.
  • opening your editor, lang server starts, opening a file with many/all schema's in your app => I haven't tested setting many schemas in the same file but I wouldn't recommend that.
  • building your project with tsc => Experience is still very smooth, it took ~20seconds on my project

@marcelbeumer
Copy link
Author

Thanks @ThomasAribart and @rattrayalex. Those metrics are they just for the schema part (by testing difference with and without schemas) or are those for full project code?

@rattrayalex
Copy link

Full projects. There haven't been isolated benchmarks on just schemas.

@ThomasAribart ThomasAribart added the documentation Improvements or additions to documentation label Jul 18, 2021
@ThomasAribart ThomasAribart self-assigned this Jul 18, 2021
@ThomasAribart
Copy link
Owner

Sorry it took some time but I added a FAQ section with a paragraph on the subject !

Closing this issue !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants