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

cache compilations to speed up startup #63

Merged
merged 19 commits into from
Oct 12, 2020
Merged

cache compilations to speed up startup #63

merged 19 commits into from
Oct 12, 2020

Conversation

ryanatkn
Copy link
Owner

This PR introduces more sophisticated caching to avoid unnecessary work on startup. Previously, the Filer re-compiled everything on startup and then compared results to what was on disk, which is usually wasted work. The Filer now stores a JSON metadata file corresponding to each source file (including externals) with the minimum amount of information needed to rehydrate compilations on startup. Right now, this metadata includes 1) a hash of the source contents, 2) a list of the compiled files' paths, which correspond to built files on disk, and 3) their encoding, like utf8 or null.

By combining the metadata with the built files on disk, we can avoid re-compiling files on startup. This cut the gro dev startup time in half for Gro itself, and for frontend projects that use a lot of Svelte, this could improve startup time by orders of magnitude, depending on the size of the project.

There remain corner cases that require the developer to manually clear the cache, like updating dependencies or changing compilation options that aren't handled by the Filer. We can mitigate some of these problems down the road - for now, if something looks off, gro clean should be the go-to fix.

@ryanatkn ryanatkn merged commit 504f1d6 into master Oct 12, 2020
@ryanatkn ryanatkn deleted the cache-compilations branch October 12, 2020 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant