treasure-data / omnibus-td-agent

td-agent (Fluentd) Packaging Scripts
https://docs.treasuredata.com/articles/td-agent-changelog
Apache License 2.0
82 stars 131 forks source link

Investigate optimizing the size of the td-agent package? #32

Open mr-salty opened 9 years ago

mr-salty commented 9 years ago

Hi, I have noticed the td-agent package is quite large at ~75MB, and when installed it consumes ~200MB in /opt. I did a brief investigation, here are some notes (all of these are based on the installed size):

If we are able to make all of those changes, the size of the installed /opt/td-agent is reduced from 206MB to 97MB. I didn't build a package but as an approximation I tar/gzipped the directory which was reduced in size from 76MB to 18MB (!).

This isn't an urgent problem but it would be nice to reduce the size.

repeatedly commented 9 years ago

Hi @mr-salty

Awesome investigation :+1: For td, including pkg is not needed and other some files could be removed. I will try to remove these files to reduce package size.

repeatedly commented 9 years ago

td command issue is resolved: https://github.com/treasure-data/td/pull/43 ruby's cache will be removed: https://github.com/treasure-data/omnibus-td-agent/pull/33

I will work on removing other files later.

repeatedly commented 9 years ago

Using latest commit, td-agent 2 size becomes 2x smaller than before. cc0d8d46b919dd95068ffe8ded4d0a19

none of the binaries/libraries are stripped - doing this saves about 50MB.

Do you have a list of stripped binaries?

mr-salty commented 9 years ago

Awesome, thanks!

For my experiment I just did something like find "/opt/td-agent -type f | xargs strip" but hopefully there is a better way to do it during the build process. I can look into it.

repeatedly commented 9 years ago

I see. Maybe, keeping the debug info of Ruby and related libraries is better. I will check which td-agent libraries could be stripped or not.

mr-salty commented 9 years ago

I was looking for information about stripping when building ruby gems (which would solve part of the problem). Although I thought this would be a common thing to do, I couldn't find much info about it.

It looks like it may be possible to pass some cflags (-s would be good) although I'm not entirely sure how to accomplish this for our purposes (do you have to configure every gem independently? That would be a pain): http://stackoverflow.com/questions/6761670/is-there-any-way-to-change-gcc-compilation-options-for-a-gem