[Feat] Memoize getDefinition
parser function
#361
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been working on schemas for Github webhook events with the goal of generating types from the schemas - we recently merged the initial schemas, and so I've gotten to the point of actually generating the types from the
schema.json
generated by runningnpm run build:schema
on this pr.The
schema.json
is quite large - just shy of 30000 lines, and currently it takes ~120 seconds to build the.d.ts
file.While I know this is to be expected when running large schemas, I did some basic poking around and found that the bulk of the bottleneck is in the
getDefinitions
parser method.That method had a jsdoc block with the comment "TODO: Memoize" so on a whim I decided to see how fast it'd be if I did just that.
Turns out it'll be 96.4% times faster, taking the time from ~120 seconds down to ~3 seconds while still generating an identical schema.