Giter Site home page Giter Site logo

Comments (13)

ralphtheninja avatar ralphtheninja commented on July 16, 2024 3

We're down to 56Mb now, so I think this can be closed. We could spend endless time to optimize more but I don't think it will give us that much more bang for the buck.

https://github.com/deltachat/deltachat-desktop/releases/tag/v1.2.2

from deltachat-desktop.

okdistribute avatar okdistribute commented on July 16, 2024 1

Here’s a PR on another project that reduces build size using electron-builder without two package json (look at package.json) https://github.com/cabal-club/cabal-desktop/pull/85/files

from deltachat-desktop.

ralphtheninja avatar ralphtheninja commented on July 16, 2024

I suspect this is due to node_modules/ containing development modules. We might want to split up the app using the Two package.json structure. Simply put, move everything related to the app into an app folder and keep all development related dependencies in the root package.json.

from deltachat-desktop.

ralphtheninja avatar ralphtheninja commented on July 16, 2024

@Karissa Do you think the two package.json structure is the way to go? I could take a stab at this.

from deltachat-desktop.

okdistribute avatar okdistribute commented on July 16, 2024

I have never tried that — it seems like it should be unecessary to do that perhaps it’s the easiest to implement. I hear people complain about the two package json structure and there could be another way..

from deltachat-desktop.

ralphtheninja avatar ralphtheninja commented on July 16, 2024

If I understand this correctly you need to use yarn? https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

I hear people complain about the two package json structure

What are they complaining about?

from deltachat-desktop.

ralphtheninja avatar ralphtheninja commented on July 16, 2024

I spent some time investigating what's causing this size. Below are my findings:

Prepare

Skip generating .deb file to increase speed of test. Also it's not relevant to the test.

I did a quick check on the folders and they are fairly small:

$ du -sh src/ es5/ build/ bin/ images/ _locales/ static/
144K    src/
164K    es5/
64K     build/
16K     bin/
300K    images/
212K    _locales/
2,0M    static/

It must be the node_modules/ folder that's causing the big size.

test command

I used the following command for testing size.

rm -rf node_modules/ && npm i && rm -rf dist/ && npm run dist; ls -al dist/*.AppImage

The last ; is because npm run dist fails due to missing github credentials.

devDependencies

First lets try if it's a problem with devDependencies being included.

  1. size of .AppImage file: 214518973 bytes
  2. remove standard -> 214518649 bytes (-324 bytes)
  3. remove nodemon -> 214518789 bytes (+140 bytes)
  4. remove babel-eslint -> 214519372 bytes (+583 bytes)
  5. remove buble (install globally instead) -> 214518986 bytes (-386 bytes)
  6. remove depcheck (not used) -> 214518885 bytes (+/- whatever bytes)

I think it's fairly clear that devDependencies isn't affecting the resulting image at all, since removing some dependencies adds size to the resulting binary. Also, this is in the magnitude of hundreds of bytes, which is uninteresting. Apparently electron-builder handles this in a good way.

Lets move on to dependencies.

dependencies

Lets also revert all devDependencies and start from scratch.

  1. size of .AppImage file: 214518973
  2. remove deltachat-node -> 200066198 (-14452725), apparently has a bit of effect but "only" 14Mb, there must be something else taking up more space (we might be able to reduce this size as well)
  3. remove react -> 200065813 (-385), i.e. 0 effect
  4. remove react-dom -> 200066045 (+232), i.e. 0 effect
  5. remove react-intl -> 198946736 (-1119309), 1Mb so not a lot
  6. remove run-parallel -> 198942483 (-4253), hardly noticable effect
  7. remove lodash.merge -> 198938535 (-3948), hardly noticable effect
  8. remove intl-tel-input -> 198491122 (-447413), ~450k so not a lot
  9. remove insert-css -> 198491286 (+164), i.e. 0 effect
  10. remove emoji-panel -> 165022652 (-33468634), ~32Mb so quite a bit, but still a lot to go (this should/could be optimized)
  11. remove debounce -> 165017952 (-4700), hardly noticable effect
  12. remove conversations -> (errors due to missing react and react-dom so putting them back) -> 54294609, so roughly 110Mb effect (highest prio)
  13. remove application-config -> 54290421 (-4188), hardly noticable effect
  14. remove @blueprint/core -> 51215169 (-3075252), ~3Mb so not a lot
  15. remove arch -> 51211202 (-3967), hardly noticable effect

conclusion

We should look further into optimizing the following dependencies and see what's causing this. And in this order.

  1. conversations (110Mb)
  2. emoji-panel (32Mb)
  3. deltachat-node (14Mb)

from deltachat-desktop.

ralphtheninja avatar ralphtheninja commented on July 16, 2024

@Karissa Side note: I went through the cabal-desktop process and it's not really different from ours, since I only used npm to build the cabal desktop app and still produces a good sized binary, which lead me to this dependency quest to get more information.

from deltachat-desktop.

ralphtheninja avatar ralphtheninja commented on July 16, 2024

Jumped into conversations a bit.

$ npm i --production
$ du -sh node_modules/
121M    node_modules/

Used Disk Usage Analyzer:

screenshot from 2018-09-29 18-19-27

It seems the emoji-datasource module is the culprit here.

Checking conversations where this is used:

$ git grep -n -C3 emoji-datasource`

screenshot from 2018-09-29 18-25-28

So, it seems conversations isn't using emoji-datasource directly. How about indirectly? (ag is the_silver_searcher)

$ ag -a emoji-datasource

screenshot from 2018-09-29 18-27-46

There seems to be no usage of emoji-datasource whatsover. But conversations depend on emoji-js. So somewhere around here we should make a decision. Maybe fork emoji-js and just remove all that crap? :)

It's basically just a bunch of .png files:

$ ls -al node_modules/emoji-datasource/
total 108992
drwxr-xr-x  2 lms lms     4096 sep 29 17:59 .
drwxr-xr-x 24 lms lms     4096 sep 29 17:59 ..
-rw-r--r--  1 lms lms     3445 nov 17  2017 CHANGES.md
-rw-r--r--  1 lms lms   983922 nov 17  2017 emoji.json
-rw-r--r--  1 lms lms  1629054 nov 17  2017 emoji_pretty.json
-rw-r--r--  1 lms lms     1080 apr  6  2017 LICENSE
-rw-r--r--  1 lms lms     2042 sep 29 17:59 package.json
-rw-r--r--  1 lms lms     4832 nov 17  2017 README.md
-rw-r--r--  1 lms lms  1611272 nov 17  2017 sheet_apple_16.png
-rw-r--r--  1 lms lms  2287847 nov 17  2017 sheet_apple_20.png
-rw-r--r--  1 lms lms  4774502 nov 17  2017 sheet_apple_32.png
-rw-r--r--  1 lms lms 13693323 nov 17  2017 sheet_apple_64.png
-rw-r--r--  1 lms lms  1460924 nov 17  2017 sheet_emojione_16.png
-rw-r--r--  1 lms lms  2038219 nov 17  2017 sheet_emojione_20.png
-rw-r--r--  1 lms lms  4025880 nov 17  2017 sheet_emojione_32.png
-rw-r--r--  1 lms lms  8962564 nov 17  2017 sheet_emojione_64.png
-rw-r--r--  1 lms lms  1500486 nov 17  2017 sheet_facebook_16.png
-rw-r--r--  1 lms lms  2086626 nov 17  2017 sheet_facebook_20.png
-rw-r--r--  1 lms lms  4169966 nov 17  2017 sheet_facebook_32.png
-rw-r--r--  1 lms lms 10785774 nov 17  2017 sheet_facebook_64.png
-rw-r--r--  1 lms lms  1454327 nov 17  2017 sheet_google_16.png
-rw-r--r--  1 lms lms  2008386 nov 17  2017 sheet_google_20.png
-rw-r--r--  1 lms lms  3843575 nov 17  2017 sheet_google_32.png
-rw-r--r--  1 lms lms  9462647 nov 17  2017 sheet_google_64.png
-rw-r--r--  1 lms lms  1559060 nov 17  2017 sheet_messenger_16.png
-rw-r--r--  1 lms lms  2196115 nov 17  2017 sheet_messenger_20.png
-rw-r--r--  1 lms lms  4503752 nov 17  2017 sheet_messenger_32.png
-rw-r--r--  1 lms lms 12502765 nov 17  2017 sheet_messenger_64.png
-rw-r--r--  1 lms lms  1274797 nov 17  2017 sheet_twitter_16.png
-rw-r--r--  1 lms lms  1733472 nov 17  2017 sheet_twitter_20.png
-rw-r--r--  1 lms lms  3268949 nov 17  2017 sheet_twitter_32.png
-rw-r--r--  1 lms lms  7693547 nov 17  2017 sheet_twitter_64.png

from deltachat-desktop.

hpk42 avatar hpk42 commented on July 16, 2024

from deltachat-desktop.

ralphtheninja avatar ralphtheninja commented on July 16, 2024

@hpk42 We can go much lower than that if we tweak these dependencies a bit. Around 50-60Mb should be doable.

from deltachat-desktop.

hpk42 avatar hpk42 commented on July 16, 2024

great!

from deltachat-desktop.

r10s avatar r10s commented on July 16, 2024

very cool :)

from deltachat-desktop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.