Executable file size

RCF support and general discussion.
Post Reply
Dirk
Posts: 3
Joined: Thu May 02, 2013 7:45 am

Executable file size

Post by Dirk »

I'm looking for a library that allows me to call C++ code over a network connection, and RCF looks like a very nice fit.

However, while doing some initial tests I was unpleasantly surprised by the resulting file size. I compiled the demo application, and the resulting file size of the Client and Server application was about 6.5MB each. That was much larger than I expected, and makes the library unsuited for our purpose (we need to run on an embedded platform, with limited resources).

So my question is if this file size is expected, and if anything can be done to reduce it. I have so far only done tests on my host platform, which is a 64-bit linux installation.

Command line used to compile:
g++ Server.cpp ../src/RCF/RCF.cpp -I../../../boost/boost_1_53_0 -I../include -lpthread -ldl -o Server
resulting file:
6850862 Apr 30 11:39 Server

Effort to reduce the file size as much as possible:
g++ Client.cpp ../src/RCF/RCF.cpp -I../../../boost/boost_1_53_0 -I../include -lpthread -ldl -Os -o Client
strip Client
resulting file:
2049896 May 2 09:49 Client

2MB is a step in the right direction, but it's still much larger than I expected. Is this a normal result?

By the way: the compilation instructions for linux platforms don't include the -ldl option, you might want to add that.

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: Executable file size

Post by jarl »

I would expect lower file size than that, but it is difficult to make any predictions.

For comparison, when building RCF as a DLL with Visual Studio 2012, in 32 bit release, the resulting DLL is 1289 kb.
The same DLL, when built in 64 bit release, is 1910 kb.

If I instead build a simple application with a couple of RCF servers and clients in it, and compile RCF.cpp directly into the executable, the size of the resulting EXE is 991kb (32 bit release). The reason it's smaller than the DLL, is that the Visual C++ linker has stripped out all the RCF features that the application isn't using.

Basically the executable sizes jump around quite a bit, depending on things like:

1) Debug or release build
2) Compiler
3) Architecture (x86, x64)
4) Build method (as DLL, or compiled directly into application).

In the past we haven't really exerted ourselves to minimize file size, as 1-2 Mb tends to be acceptable on a lot of platforms. I would like to see it smaller though, and the easiest way to do that would be to have a cut down build with core features. Can you tell us which features you need, and what an acceptable file size would be?

Thanks for the note on -ldl ... I will add that to the documentation.
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

Dirk
Posts: 3
Joined: Thu May 02, 2013 7:45 am

Re: Executable file size

Post by Dirk »

I just compiled the demo code, so it is compiled directly into the application. gcc is usually intelligent enough to strip unused code, so I'm assuming it does that in this case too.
It also surprised me that the code took such a long time to compile. On my Intel i5 M520 (2.4GHz) it takes about a minute to compile just the client. But seeing the resulting file size, that is probably expected.

As for features, I'm not familiar enough with RCF to indicate which features we could live without. Basically what we need is the ability to call C++ code over the network, where RCF would handle generating the stubs and providing the network communication. From the documentation, what we don't need includes file transfer, authentication, encryption, compression, tunneling, json support, protocol buffers support. Probably more, but I need to spend more time using RCF first.

To me, it would be a welcome addition that one could define the features that are needed using compile time switches so unneeded features are not included. That's most likely a big change for your code base though. I must admit I haven't looked at the code at all yet, but I wanted to ask the question first before I dive in :)

As for size, since we're looking to use it in an embedded context, every byte counts. I was (perhaps naively) expecting something about 10 times smaller in resulting file size... Our complete application is only 5MB in size, so adding an extra MB just for network communication seems out of proportion.

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: Executable file size

Post by jarl »

I've had a go at stripping the codebase down to a minimum, and ended up with an executable containing a TCP server and client, with a size of 500kb. That's to be compared to a size of 1Mb, before I started stripping code out.

With a bit more work I'm pretty sure it can go a ways under 500kb as well. What we'll do is, as you suggested, to introduce a number of defines so that end users can easily remove functionality they're not using. A first cut of this should be available soon (with a minimum file size of around 500kb).

Re compile times - because RCF compiles as a single source file, the compiler needs a fair bit of memory, and if it doesn't have enough, compile times will suffer. Also, in my own experience, Visual C++ has always seemed a bit faster than gcc. On my own development box (Xeon 3.4 GHz, 16Gb) with Visual Studio 2012, RCF.cpp currently compiles in about 13 seconds.
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

Dirk
Posts: 3
Joined: Thu May 02, 2013 7:45 am

Re: Executable file size

Post by Dirk »

Sounds great! Looking forward to the stripped version.

Compile times are obviously not a deal breaker, it's just an annoyance. I only did a compile on my personal laptop and not on the build server, so I do expect a performance increase there.

Thanks!

Post Reply