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

Improve load performance #482

Merged
merged 1 commit into from Jun 11, 2020
Merged

Improve load performance #482

merged 1 commit into from Jun 11, 2020

Conversation

FredKSchott
Copy link
Owner

Based off work from https://github.com/GoogleCloudPlatform/require-so-slow

  • defer loading of css-modules-loader-core
  • defer loading of chokidar

These were our two worst offenders in terms of load time performance impact.

@stramel
Copy link
Contributor

stramel commented Jun 11, 2020

What kind of perf improvements did this yield?

@FredKSchott
Copy link
Owner Author

Should have included in the OP:

Screen Shot 2020-06-11 at 12 11 15 PM

The flamegraph implied that this was a 50% startup saving, but my quick manual test of the changes only saw a speedup from .27 sec -> .21 sec (~25% speedup).

@stramel
Copy link
Contributor

stramel commented Jun 11, 2020

I wonder if we swapped got out for something simpler like bent would decrease the load time for that?

got ~28kb
bent ~1kb

https://github.com/mikeal/bent

@@ -66,8 +67,8 @@ export async function wrapCssModuleResponse({
hasHmr?: boolean;
config: SnowpackConfig;
}) {
let core = new Core();
const {injectableSource, exportTokens} = await core.load(code, url, () => {
_cssModuleLoader = _cssModuleLoader || new (require('css-modules-loader-core'))();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use require() here, since TypeScript's import support forces us to grab the default export off of the module, but that doesn't actually exist. But, we still get type info from the CSSModuleLoader type above.

@FredKSchott
Copy link
Owner Author

+1, we only use got for our experimental webDependencies support, could be worth checking out.

@FredKSchott FredKSchott merged commit 4f9403b into master Jun 11, 2020
@FredKSchott FredKSchott deleted the wip-perf-improve branch June 11, 2020 23:13
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.

None yet

3 participants