Native libgrpc_csharp_ext.x64.so is too large, possible to reduce size?

776 views
Skip to first unread message

toka...@gmail.com

unread,
Oct 2, 2018, 3:03:06 PM10/2/18
to grpc.io
libgrpc_csharp_ext.x64.so, the native Grpc library for Linux,  is 15.2 Mb. For my application the size of the package is key (it runs in a containerized environment). I'm using an ultra-small Linux image, Alpine, which is only a couple of megabytes, and I need to get the app size way down. Is it possible to get a smaller build of libgrpc_csharp_ext.x64.so - even if it would only support a specific image?

Christopher Warrington - MSFT

unread,
Oct 2, 2018, 6:23:25 PM10/2/18
to grpc.io
On Tuesday, October 2, 2018 at 12:03:06 PM UTC-7, toka...@gmail.com wrote:

> libgrpc_csharp_ext.x64.so, the native Grpc library for Linux, is 15.2 Mb.
> For my application the size of the package is key (it runs in a
> containerized environment). I'm using an ultra-small Linux image, Alpine,
> which is only a couple of megabytes, and I need to get the app size way
> down.

*Possible mitigation* if you are using a layer-based image format (e.g.,
Docker images): can you construct you image with an Alpine layer, then a
gRPC dependencies layer, then your application? This will allow the 15 MiB
to be shared across different images and only pulled to the hosting machine
once.

--
Christopher Warrington
Microsoft Corp.

Jan Tattermusch

unread,
Oct 4, 2018, 5:55:38 AM10/4/18
to grpc.io
The libgrpc_csharp_ext.x64.so is that size because it is unstripped and contains debug symbols (we keep the debug symbols because they make it much easier to diagnose an issue in case of a grpc problem)

libgrpc_csharp_ext.x64.so: ELF 64-bit LSB shared object x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e81cf405a65678e7791e4cab0fa1d98ee6904ff0, with debug_info, not stripped

if you want to shrink the version of your images, you can  strip the libgprc_csharp_ext.x64.so (e.g. after building the app or running "dotnet publish") yourself:

$ strip --strip-debug libgrpc_csharp_ext.x64.so
libgrpc_csharp_ext.x64.so: ELF 64-bit LSB shared object x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e81cf405a65678e7791e4cab0fa1d98ee6904ff0, stripped

That will reduce the size of the library to less than 3MB. With the stripped version of the binary, everything will work normally, but your ability do debug a problem will be reduced due to missing debug symbols.
Reply all
Reply to author
Forward
0 new messages