Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Is there any way to reduce the release executable size? #627

Closed
dzcpy opened this issue Sep 6, 2022 · 5 comments · Fixed by #632
Closed

Is there any way to reduce the release executable size? #627

dzcpy opened this issue Sep 6, 2022 · 5 comments · Fixed by #632
Labels
support Issues related to support questions

Comments

@dzcpy
Copy link

dzcpy commented Sep 6, 2022

Hi, thank you for write this awesome tool. I'm currently building a software which requires the package to be within a certain size. However I just tested the example code in the readme, after relase build it takes more than 80M. Besides compressing it using something like UPX, is there anyway to reduce the executable size? Why it take so much space?
Here below is the result from running cargo bloat --release --crates using cargo-bloat
image

@Kerollmops
Copy link
Member

Hey @dzcpy,

You can maybe try using the strip command it could probably help. It removes the debug symbols from the binary.

@curquiza curquiza added the support Issues related to support questions label Sep 6, 2022
@dzcpy
Copy link
Author

dzcpy commented Sep 6, 2022

Hi @Kerollmops, thanks for your quick reply. However I'm using the following cargo config which I believe debug symboles have already been removed:

[profile.release]
opt-level = 'z'     # Optimize for size.
lto = true          # Enable Link Time Optimization
codegen-units = 1   # Reduce number of codegen units to increase optimizations.
panic = 'abort'     # Abort on panic
strip = true        # Strip symbols from binary*

I also tried that difference between debug and release modes is only around 10M. Could you shed some light on how to further lower the size of the binary? Thanks

@Kerollmops
Copy link
Member

Kerollmops commented Sep 7, 2022

Hey @dzcpy,

Unfortunately, I can't help you more than that as I am not an expert on this subject. however, you can look at this guide repository which will surely help you reduce the binary size furthermore. I will close this issue as this is not something we want to prioritize any time soon.

Have a nice day 🏝

@vincent-herlemont
Copy link
Contributor

vincent-herlemont commented Sep 7, 2022

I can purpose a solution to reduce the size of ~90% (from ~92.1MiB to ~8.9MiB).

The solution is to ignore tokenizing for these languages "chinese", "hebrew", "japanese", "thai" (charabia/Cargo.toml#L28).

I have purposed a PR here #632. This PR seems does not change the current behavior of the crate but allows the possibility to remove the support of the above languages.

  • milli = { path = "../milli/milli" }: ~92.1MiB
  • milli = { path = "../milli/milli", default-features = false }: ~8.9MiB

@vincent-herlemont
Copy link
Contributor

Just for information ~85% of the size of the binary is taked by crates/lindera-ipadic which used by meilisearch/charabia/Cargo.toml#L24.

bors bot added a commit that referenced this issue Sep 8, 2022
632: Make charabia default feature optional r=ManyTheFish a=vincent-herlemont

# Pull Request

## What does this PR do?
Fixes [#627](#627 (comment))

Thank you so much for contributing to Meilisearch!


Co-authored-by: Vincent Herlemont <vincent@herlemont.fr>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support Issues related to support questions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants