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

Reduce the binary size of ceresdb-server #294

Closed
ShiKaiWi opened this issue Oct 11, 2022 · 5 comments
Closed

Reduce the binary size of ceresdb-server #294

ShiKaiWi opened this issue Oct 11, 2022 · 5 comments
Assignees
Labels
feature New feature or request help wanted Extra attention is needed

Comments

@ShiKaiWi
Copy link
Member

Describe this problem

Now the compiled ceresdb-server's size has reached up to 1.3GB, which is unbelievable.

Steps to reproduce

Just compile the ceresdb-server and check its size.

Expected behavior

The binary size should not be so large.

Additional Information

The way to reduce the binary size that I can come up with now is to remove the unused dependencies, including:

  • Replace protobuf with prost used by protos crate so to remove grpcio dependencies;
  • ...
@ShiKaiWi ShiKaiWi added bug Something isn't working feature New feature or request and removed bug Something isn't working labels Oct 11, 2022
@jiacai2050
Copy link
Contributor

Don't expect it's already exceed 1G. but after strip it, it's just 59M, so this issue may not very serious, at least for now.

$ ll -h target/release/ceresdb-server ~/bench/ceresdb-server 
-rwxr-xr-x 1 chenxiang chenxiang 1.3G Oct  9 17:11 /home/chenxiang/bench/ceresdb-server
-rwxr-xr-x 2 chenxiang chenxiang  59M Oct 11 21:44 target/release/ceresdb-server

@jiacai2050
Copy link
Contributor

#322 reduce binary size to 500M, but at the cost of long build, we can introduce more profiles to balance size and speed.

IOx have a quick-release profile

@waynexia
Copy link
Member

strip removes debug info to reduce the binary size. Here is my release binary size without the release.profile.debug = true:

➜  ceresdb git:(main) ✗ ll -h target/release/
Permissions Size User    Date Modified Name
drwxr-xr-x     - ruihang 10 11 20:19   build
.rwxr-xr-x   61M ruihang 10 11 20:23   ceresdb-server
.rw-r--r--   18k ruihang 10 11 20:23   ceresdb-server.d
drwxr-xr-x     - ruihang 10 11 20:23   deps
drwxr-xr-x     - ruihang 10 11 20:19   examples
drwxr-xr-x     - ruihang 10 11 20:19   incremental
.rw-r--r--   18k ruihang 10 11 20:23   libceresdb.d
.rw-r--r--   17M ruihang 10 11 20:23   libceresdb.rlib

So the strip is not a feasible way, otherwise we can just eliminate it on building.

reduce binary size to 500M, but at the cost of long build

link unit and lto are not only the size reducing options. They may also have influence on performance. Maybe open them on every formal release is a better choice. (or lto = "full", might be even better)

@ShiKaiWi
Copy link
Member Author

ShiKaiWi commented Nov 10, 2022

So the strip is not a feasible way, otherwise we can just eliminate it on building.

It's true. Debug information is necessary for us to troubleshoot in prod env.

In #322, what matters most to reduce binary size is actually the option: opt-level = "z". However, this may cause performance degradation, and for this reason #322 has been reverted already.

@jiacai2050
Copy link
Contributor

It's true. Debug information is necessary for us to troubleshoot in prod env.

-Csplit-debuginfo just get stabilized in 1.65, so we may can rely on this to both reduce binary size and still have to ability to debugging.

@jiacai2050 jiacai2050 reopened this Nov 25, 2022
@mrrtree mrrtree self-assigned this Mar 13, 2023
@jiacai2050 jiacai2050 removed the good first issue Good for newcomers label May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants