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

Desktop: Fixes #11405: Reduce application size by removing unnecessary Rust files #11412

Merged
merged 7 commits into from
Nov 28, 2024

Conversation

pedr
Copy link
Collaborator

@pedr pedr commented Nov 18, 2024

Fixes #11405

Summary

After the inclusion of the onenote-converter package to the project, the release build had a 100MB+ increase in size.

Format 3.2.1 3.2.3
AppImage 238 MB 369 MB
dmg 232 MB 367 MB
exe 340 MB 527 MB

This PR addresses that by removing the target folder used by Rust to store build and was being imported to the application bundle.

After this PR:

Format 3.2.1 3.2.3 This PR
AppImage 238 MB 369 MB 270 MB

Further work:

The biggest contributors to the size are:
image

It seems like the packages are duplicated, for example @joplin/renderer requires mermaid, but @joplin/lib by requiring @joplin/renderer also has mermaid inside of it.

Not sure how much work, but I think we might be able to cut down some MBs with a way to remove duplication when they happen. (maybe this already happen on the executable and it is only visible when the asar is unpacked??)

Testing

  1. Run git clean -dfx on project root
  2. Run yarn
  3. Run cd packages/onenote-converter && IS_CONTINUOUS_INTEGRATION=1 yarn build
  4. Run cd ../app-desktop
  5. Run yarn dist
  6. Run ls -lah dist/
  7. Check size of the executable
  8. Run ./dist/Joplin-3.2.3.AppImage and make sure it is working

@pedr pedr added bug It's a bug desktop All desktop platforms labels Nov 18, 2024
@pedr pedr requested a review from laurent22 November 18, 2024 20:04
@laurent22
Copy link
Owner

Thanks Pedro, so what is causing this 30 MB increase in size?

@pedr
Copy link
Collaborator Author

pedr commented Nov 20, 2024

Thanks Pedro, so what is causing this 30 MB increase in size?

I'm going to build the two versions and see why the difference is appearing.

@pedr
Copy link
Collaborator Author

pedr commented Nov 20, 2024

Thanks Pedro, so what is causing this 30 MB increase in size?

When comparing the two AppImages unpacked, the biggest change has been on @joplin/renderer which increased its size from 100MB to 152MB, from that being 36MB from mermaid library and 9.2MB from cytoscape-fcose (which is a new dependency of mermaid).

Note that these sizes are before packaging so that they are so high. Comparing node_modules of @joplin/renderer I got:

Details
Biggest packages on @joplin/renderer         Biggest packages on @joplin/renderer  
             
408K ./d3-geo       332K ./uuid
412K ./d3-sankey       352K ./d3-format
416K ./@Chevrotain       368K ./dagre-d3-es
420K ./d3-contour       376K ./micromark-core-commonmark
428K ./layout-base       384K ./d3-shape
480K ./khroma       392K ./iconv-lite
512K ./acorn       408K ./d3-geo
724K ./markdown-it       412K ./d3-sankey
728K ./dompurify       420K ./d3-contour
828K ./@iconify       428K ./layout-base
1,1M ./marked       464K ./diff
1,2M ./d3       472K ./khroma
1,7M ./dayjs       700K ./dompurify
1,8M ./chevrotain       724K ./markdown-it
2,7M ./lodash-es       1,2M ./d3
4,1M ./langium       1,7M ./dayjs
4,3M ./katex       2,7M ./lodash-es
4,9M ./cytoscape       4,3M ./katex
4,9M ./@mermaid-js       4,9M ./cytoscape
9,1M ./highlight.js       7,7M ./elkjs
9,2M ./cytoscape-fcose       9,1M ./highlight.js
23M ./@joplin       23M ./@joplin
64M ./mermaid       28M ./mermaid
148M .       96M .

I'm not sure how easy it will be to understand, but when I was investigating I saved some logs to compare again:
size differences.ods

@@ -61,7 +61,7 @@ export default class InteropService_Importer_OneNote extends InteropService_Impo
const outputDirectory2 = join(tempOutputDirectory, baseFolder);

const notebookFiles = zip.getEntries().filter(e => e.name !== '.onetoc2' && e.name !== 'OneNote_RecycleBin.onetoc2');
const { oneNoteConverter } = shim.requireDynamic('../../../onenote-converter/pkg/onenote_converter');
const { oneNoteConverter } = shim.requireDynamic('../../node_modules/@joplin/onenote-converter/pkg/onenote_converter');
Copy link
Owner

Choose a reason for hiding this comment

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

This needs to be updated

@laurent22 laurent22 merged commit eb5c460 into laurent22:dev Nov 28, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug desktop All desktop platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Release file size increased in v3.2.3
2 participants