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

docs: Performance checklist #20230

Merged
merged 21 commits into from Oct 21, 2019
Merged

docs: Performance checklist #20230

merged 21 commits into from Oct 21, 2019

Conversation

felixrieseberg
Copy link
Member

@felixrieseberg felixrieseberg commented Sep 13, 2019

Description of Change

This PR introduces a performance checklist. It's a bit self-documenting, but I'd like to highlight that it's not meant to be prescriptive or exhaustive.

For internal discussion, see #proj-performance-docs.

Checklist

Release Notes

Notes: Added a performance checklist

@felixrieseberg felixrieseberg requested a review from a team September 13, 2019 19:51
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Sep 13, 2019
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 14, 2019
@PalmerAL
Copy link
Contributor

This seems fairly comprehensive, and it covers a lot of the things I've run into in the past. A few more things that it might make sense to add:

  • Even if your app shares code with your website, you should bundle resources in your app rather than loading them over HTTP.
  • In most cases, it's better to bundle your code together rather than trying to require() everything on startup.
  • I know you mentioned it already, but it might be a good idea to emphasize more just how slow remote is, since it's one of the largest Electron-specific sources of slowness.
  • Minimizing resource usage when the app is running in the background.

It might also be interesting to talk about the differences in user expectations between a website and a desktop app. I think most people have gotten used to websites being somewhat slow, but don't have the same expectations for desktop apps, so if you're working with Electron for the first time, you may need to focus on performance more than you would in the past.

@MarshallOfSound
Copy link
Member

Even if your app shares code with your website, you should bundle resources in your app rather than loading them over HTTP.

I wouldn't recommend this this point blank. There are significant cons to this, namely version drift and the fact that updating your website now means you have to update your app as well. Their are significant pros and cons to live-loading and shipping in-app and I don't think we can recommend one without a comprehensive list of those pros and cons which I don't think belongs in this document.

In most cases, it's better to bundle your code together rather than trying to require() everything on startup.

👍 Especially on windows, file system ops are slow ™️

Minimizing resource usage when the app is running in the background.

Mentioning putting things into requestAnimationFrame or checking document.visibilityState might be good here

@issacgerges
Copy link

Really great stuff @felixrieseberg! This is going to make a massive impact. Just some stuff that comes to mind when reading:

  • My number one tool for demonstrating the cost of work in the main process has been Johannes' fiddle. Curious if it would be worth including examples like this one when it makes sense https://twitter.com/johannesrieken/status/1086311961128620032

  • Love the warning around remote, but I wonder if remote.getGlobal deserves special attention. I think people rarely understand the performance trade-off there, partly because the API hides a lot of the complexity around this almost magic front. I think it may be hard for people to understand that calls like remote.getGlobal('settings').getTheme().topBar.color is around 10 ipc messages back and forth.

  • For unnecessary polyfills, it might be worthwhile to mention that electron is a valid target as a browserlist and can be used with @babel/preset-env

  • It's well documented, but I wonder if the Measure, Measure, Measure section deserves to link out to https://electronjs.org/docs/tutorial/debugging-main-process.

  • Should devtron be called out? Might be some overlap with the require graph / ipc stuff and some of what you've called out here.

docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
@felixrieseberg felixrieseberg marked this pull request as ready for review September 18, 2019 18:32
## Checklist

Chances are that your app could be a little leaner, faster, and generally less
resource-hungry if you attempt these steps.
Copy link
Member

Choose a reason for hiding this comment

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

1 through 6 are titled as things you should not do, 7 is something you should do. Combined with "attempt these steps" above, it seems like all things you should do, so maybe rewrite the intro line to:

Chances are that your app could be a little leaner, faster, and generally less 
resource-hungry if you review the following checks.

Or change the titles of 1 through 6 to be the thing you should do, which is mostly adding "Don't" in front of the current titles.

Copy link
Member

@malept malept left a comment

Choose a reason for hiding this comment

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

This is great! My comments are mostly grammatical / formatting.

docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
docs/tutorial/performance.md Outdated Show resolved Hide resolved
felixrieseberg and others added 5 commits October 17, 2019 09:05
Co-Authored-By: Mark Lee <malept@users.noreply.github.com>
Co-Authored-By: Mark Lee <malept@users.noreply.github.com>
Co-Authored-By: Mark Lee <malept@users.noreply.github.com>
Co-Authored-By: Mark Lee <malept@users.noreply.github.com>
Co-Authored-By: Mark Lee <malept@users.noreply.github.com>
felixrieseberg and others added 2 commits October 17, 2019 09:06
Co-Authored-By: Mark Lee <malept@users.noreply.github.com>
Co-Authored-By: Mark Lee <malept@users.noreply.github.com>
@MarshallOfSound MarshallOfSound merged commit 13cb21a into master Oct 21, 2019
@release-clerk
Copy link

release-clerk bot commented Oct 21, 2019

Release Notes Persisted

Added a performance checklist

@MarshallOfSound MarshallOfSound deleted the performance-checklist branch October 21, 2019 20:40
@malept
Copy link
Member

malept commented Oct 23, 2019

This needs to go into the 7-0-x branch for it to be deployed to the website, right? (Ignoring the fact that it's not in the docs index page yet...)

@miniak
Copy link
Contributor

miniak commented Oct 26, 2019

/trop run backport-to 8-x-y

@trop
Copy link
Contributor

trop bot commented Oct 26, 2019

The backport process for this PR has been manually initiated,
sending your 1's and 0's to "8-x-y" here we go! :D

@trop
Copy link
Contributor

trop bot commented Oct 26, 2019

I was unable to backport this PR to "8-x-y" cleanly;
you will need to perform this backport manually.

@miniak
Copy link
Contributor

miniak commented Oct 26, 2019

/trop run backport-to 7-0-x

@trop
Copy link
Contributor

trop bot commented Oct 26, 2019

The backport process for this PR has been manually initiated,
sending your 1's and 0's to "7-0-x" here we go! :D

@trop trop bot mentioned this pull request Oct 26, 2019
@trop
Copy link
Contributor

trop bot commented Oct 26, 2019

I have automatically backported this PR to "7-0-x", please check out #20757

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

10 participants