-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Desktop: Performance: Faster startup and smaller application size #12366
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
Desktop: Performance: Faster startup and smaller application size #12366
Conversation
starting/compiling the app The bundle step needs to run after `tsc` processes files in the other directories. As a result, it can't run in the main `build` step.
Uses --topological-dev to have yarn consider development dependencies while topologically sorting items to be built. Earlier changes in packages/app-desktop moved deps from "dependencies" to "devDependencies", which exposed issues related to dev dependencies being built after their first attempted usage.
const bridge = require('@electron/remote').require('./bridge').default; | ||
import bridge from '../services/bridge'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since both the main and renderer scripts are bundled, require('@electron/remote').require('./bridge')
no longer results in the same instance of bridge
as is used by the main process. The bridge
must instead be transferred in a different way (see /services/bridge.ts
).
The GoToAnything searchForWithRetry seems to fail more often with the performance-related changes This commit allows a larger number of retries and adds a delay between clearing and refilling the search input.
}, | ||
"dependencies": { | ||
"@electron/remote": "2.1.2", | ||
"@joplin/onenote-converter": "~3.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular change:
- Handles the case where
@joplin/onenote-converter
is not built by default in dev mode. - Also may be required by the converter's WASM usage.
Since this isn't obvious, this should be specified in a .md
file in readme/dev/spec
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 148e76f.
CI is failing due to a scheduled brownout of the Windows 2019 action runner. This should be fixed by #12378. |
Summary
This pull request bundles the desktop app with esbuild. On Linux, this:
.AppImage
size from 219 MiB to 162 MiB.This change was also observed to improve performance on Windows 11:
Note
This pull request selects ESBuild over Webpack for two reasons:
js-draw
uses esbuild.Notes
require
s and imports are resolved at compile time. This allows moving many dependencies from"dependencies"
to"devDependencies"
, significantly reducing the application size. However, this means thatshim.requireDynamic
1) usually cannot require relative paths and 2) can only require packages present in"dependencies"
.shim.requireDynamic
calls.Testing
Testing performance: Linux
I'm using the following script to compare the performance after this change with the performance of the 3.4.1 release:
Script
At a high level, the script:
Results
Results on Fedora 42 — OS "Power Mode" set to "Performance"
Before: Startup time in seconds for Joplin v3.4.1:
After: Startup time in seconds for Joplin built from this pull request:
Percent change:$$\frac{\text{final}-\text{initial}}{\text{initial}} \times 100% = \frac{2.78-5.14}{5.14} \times 100%$$ , which is a 45.9% decrease.
Results on Fedora 42 — OS "Power Mode" set to "Power Saver"
Before: Startup time in seconds for Joplin v3.4.1:
After: Startup time in seconds for Joplin built from this pull request:
Percent change:$$\frac{\text{final}-\text{initial}}{\text{initial}} \times 100% = \frac{7.94-15.13}{15.13} \times 100%$$ , which is a 47.5% decrease.
On average, the startup time decreased by
46.7%
.Application size change: Comparing the before and after builds created by the above script,
Testing performance: Windows
Similar tests were done on Windows. Tests were done using this script, run in
git-bash.exe
.Results (Joplin portable on Windows 11): Roughly a 44% decrease in startup time
Before: Startup time in seconds for Joplin built from c9eb9af:
After: Startup time in seconds for Joplin built from this pull request:
Percent change:$$\frac{\text{final}-\text{initial}}{\text{initial}} \times 100% = \frac{5.90-10.49}{10.49} \times 100%$$ , which is roughly a 43.8% decrease.
Size change: Comparing versions of Joplin Portable built by the above script:
JoplinPortable.exe
): 319 MiBJoplinPortable.exe
): 239 MiBRegression testing
At present, this change mostly relies on automated tests. However, it has been manually verified that:
tests/support
subdirectory of the CLI app)..exe
:app-cli/tests/enex_to_md/images_with_and_without_size.enex
using file > import > "ENEX - Evernote Export File (as Markdown)".Planned manual testing to check for regressions in modified code:
HTML(not supported in the CLI app).