Should I optimize size (-O) for I / O application?

I have a C application that is heavily connected to the I / O network. It is currently compiled with -O2on gcc. Building an application using -Osshows a 20% reduction. Some basic tests did not show a noticeable decrease (or increase) in performance.

Is this a good example to build with -Os? Is there any reason not to do this? I have never seen a program that was compiled for size no matter how much time it spends on I / O operations.

+4
source share
1 answer

Optimization should not affect the actions of the program. Therefore, no type of optimization should affect the I / O network used by the program, and something else in this regard. If your program sends 10 kilobytes, it will send the same even after optimization.

Optimization may affect how structsaligned among other things (for example, code size, memory usage, etc.), but will not affect the logic at all (if programmed correctly).

Typically, since binaries tend to be relatively small (a 1 MB binary is extremely large), optimization is often used for speed rather than size. However, it is up to you.

+3
source

Source: https://habr.com/ru/post/1584674/


All Articles