BOLT icon indicating copy to clipboard operation
BOLT copied to clipboard

[Question] Is GCC -freorder-blocks-and-partition going to be handled?

Open PierreRamoin-1A opened this issue 6 years ago • 8 comments

Hi, Do you plan to handle the GCC -freorder-blocks-and-partition flag in the future? As this flag needs to be apply at compilation time, it's matter in a daily development.

We are currently using this flag on our libraries, and the need to disable it for BOLT means either deliver two version of these, either slow down every applications not using BOLT It's a big drawback of using BOLT at the moment.

If you plan to, do you have an estimated time for it?

Thanks you, Pierre

PierreRamoin-1A avatar Jul 17 '19 08:07 PierreRamoin-1A

We do plan to support it, however there's no timeline at the moment. Are you using this option with any form of compiler PGO? If it's used without PGO, do you see measurable gains?

maksfb avatar Jul 17 '19 17:07 maksfb

We don't use compiler PGO at the moment. But we might add some it in the future, which is why we needed that information. Without PGO, this flag seems to give us a small speed improvement, but too small to give accurate numbers on the program we bench-marked.

Do you know what differences on the final binary implies this flag? Is it a big change on BOLT to handle it?

PierreRamoin-1A avatar Jul 19 '19 12:07 PierreRamoin-1A

It will split some functions into hot and cold code. BOLT will do what -freorder-blocks-and-partition does, but better. The only reason we plan to support it is to avoid the recompilation issue.

maksfb avatar Jul 19 '19 22:07 maksfb

does BOLT can use compiler hint like __builtin_expect to split hot/cold code? because this is better than perf collected method sometimes

ChinaXing avatar Nov 08 '20 13:11 ChinaXing

Hi, Do you plan to handle the GCC -freorder-blocks-and-partition flag in the future? As this flag needs to be apply at compilation time, it's matter in a daily development.

We are currently using this flag on our libraries, and the need to disable it for BOLT means either deliver two version of these, either slow down every applications not using BOLT It's a big drawback of using BOLT at the moment.

If you plan to, do you have an estimated time for it?

Thanks you, Pierre

how you use this option to partition hot/cold code ? any example hopes.

I can't found any example by google

thanks:)

ChinaXing avatar Nov 08 '20 13:11 ChinaXing

-split-functions=1 will do the partitioning based on the profile. Do you have an example where __builtin_expect does a better job?

maksfb avatar Nov 08 '20 20:11 maksfb

-split-functions=1 will do the partitioning based on the profile. Do you have an example where __builtin_expect does a better job?

#include <stdio.h>
int a = 200;
int calA(int x, int y)
{
   if(__builtin_expect(!!(x > 200), 0)) {
        a+=x;
        printf("a");
   } else {
	a+=y;
   }
   return a;
}
int b = 300;
   int calB(int h, int j) {
      if(__builtin_expect(!!(h > 100), 0)) {
          b += h;
          printf("b");
      } else {
          b +=j;
      }
      return b;
   }
//extern int calA(int a, int b);
//#extern int calB(int a, int b);
int main(int argc, char **argv)
{
    int x = argv[0][0];
    int y = argv[0][1];
    return calA(x, y) + calB(x, y);
}

ChinaXing avatar Nov 09 '20 08:11 ChinaXing

If I understand correctly, there are cases not covered by profile that you want to preserve? Because in the example above there will be no samples recorded due to a short execution time. If that's the case, then without a profile BOLT should preserve the original order and the layout.

maksfb avatar Nov 09 '20 23:11 maksfb