Gcc / C ++: If the processor load is low, then code optimization is of little use, right?

My colleague likes to use gcc with '-g -O0' to create binaries for production due to debugging if the main dump happens. He says that there is no need to use compiler optimization or code tuning, because he believes that the production process does not have high CPU utilization, for example. thirty%.

I asked him the reason for this, and he told me: if the processor load is low, the bottleneck should not be our code performance and should be some IO (disk / network). Thus, the use of gcc-O2 is useless to improve latency and throughput. In addition, this also indicates that we have nothing to improve much in the code, because the processor is not a bottleneck. It is right?

+4
source share
4 answers

About optimizing processor usage

, , , , , . "" . , CPU, .

char , , , , , , & hellip; - 0,5% .

, , , 30% . , , , , , , 30% .

, - . , sleep , , , .

tl; dr: , , - .


, , . , -O0 , "" 2016 -O1 -O2. , .

-g , . 45 1 , , .

? , . , , , , .

, . (-O1), (-g); , , .

, :

  • -O2 -g
  • strip , ; .
  • , ,

, , .

+4

( ).

, 1 , CPU 0,3 - 0,7 . , 100% - , CPU , 0,3 0,15 , 0,85 1 (, - ).

, , . , ​​ 100%, , 33%, 30% , . , .

, , , - . "", . ( , "" ), , , , , . , .

+2

gcc -Og -g GCC. -Og .

, gcc -O1 -g; () , 90% -O2 ( , -O3 ). core .

. (HPC) .

, -g3 -g (, gcc -Wall -O1 -g3)

BTW , .

+1

: . , , . , .

, , . 1-2 4- . 0% , , : 30% .

, , . 10% , , , - . , , , , . 1% , , !

: , , , , . , , . " " . , , . , 15 .

, , , , , . , , - .

+1
source

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


All Articles