#1135 closed defect (fixed)

Rasdaman should not compile with -g3 when not in debug

Reported by: mdumitru Owned by: gmerticariu
Priority: critical Milestone: 9.2
Component: undecided Version: development
Keywords: Cc: dmisev, gmerticariu, pbaumann, atoader, vmerticariu
Complexity: Medium

Description

Rasdaman seems to compile with g3 flag when not in debug mode. It should be set to g0.

Change History (23)

comment:1 Changed 15 months ago by mdumitru

Ok, it seems --without-debug-symbols is disabled. Not sure why we even have such a flag, would be better to have --with-debug-symbols instead.

comment:2 Changed 15 months ago by dmisev

If I remember correctly I wanted to have it on by default as then you get a proper stacktrace on segfaults. Is there some (performance) penalty or other issue to have it on?

comment:3 Changed 15 months ago by mdumitru

With rasnet and g0: 838s and 800MB compilation memory used
With rasnet and g3: ~1400s (not sure if grpc compile as well) and 3800MB compilation memory used

comment:4 Changed 15 months ago by dmisev

I meant runtime effects of this (but it's good to know there's such a huge difference in compilation).

comment:5 Changed 15 months ago by mdumitru

I didn't check runtime performance, was trying to find a method to allow rasnet to compile in a VM and this seemed to do the trick.

comment:6 Changed 15 months ago by dmisev

Ok I'm not sure what would be a better default. Both bring some nice benefits.

Debugging an installation compiled with g0 is not possible, according to the docs -g0 negates -g, while -g is equivalent to -g2. Could you try with -g1 and -g2, and check how gdb works in these cases?

comment:7 Changed 15 months ago by mdumitru

With -g2: similar speed and 2Gb of ram used at peak

comment:8 Changed 15 months ago by mdumitru

Also at runtime the size of the binaries is considerably smaller. For rasserver with g0 it's 18MB and with g3 si 100 MB

comment:9 Changed 15 months ago by dmisev

  • Cc pbaumann atoader vmerticariu added

So -g(3) has no runtime performance penalty, all the extra MB are debug symbols in a separate part of the executable and are only loaded when debugging with gdb for example.

I'd say for us (developers) it doesn't matter which one is default. So let's focus on users, what would be better?

  • I guess if we explain the differences in the wiki:InstallFromSource, it also doesn't matter.
  • In RPMs we should use -g
  • On OSGeo Live -g0 would be better to save space on the iso
Last edited 15 months ago by dmisev (previous) (diff)

comment:10 Changed 15 months ago by mdumitru

That is true, but total size of the rasdaman installation directory is now around 700MB with the largest folders being bin and lib each having around 330 MB. It's not huge, but it could be about 5 times smaller with -g0 which would make rasdaman VMs smaller. For OSGEO Live DVD for example this is quite a problem.

Also, not having this default makes installation impossible for people without 6GB of RAM. Which again reduces the number of people that can try rasdaman on the machines.

What are the pros for using -g3 as default?

comment:11 Changed 15 months ago by gmerticariu

I propose:

default: -O3 -g0
--enable-debug: -O0, -g3

And we can remove the flags --without-optimisation-flags.

This way users who want to use rasdaman can compile it faster and without any memory penalty. For us developers we anyway need to enable debug if we want to diagnose.

comment:12 follow-up: Changed 15 months ago by dmisev

Ok sounds good. --with-optimization is useful, I'm using this to set -O0 during development. I'd prefer to have a separate --with-debug-symbols, instead of relying on --enable-debug for -g3. In the RPMs for example we should use -g2 or -g3, then debug symbols packages are automatically created, so anyone that needs the symbols for debugging can just install these packages.

To sum it up, we have these changes:

  • default: -g0
  • --without-debug-symbols -> with-debug-symbols (sets -g2 or -g3, we should investigate the differences and decide which one is preferable)

comment:13 Changed 15 months ago by dmisev

There is also an -Og flag, that might be more optimal in --enable-debug for example, instead of -O0 -g3.

comment:14 in reply to: ↑ 12 Changed 15 months ago by gmerticariu

debug symbols are not really useful if you use anything but -O3 since the debugger will jump randomly based on the optimizations made by the compiler. The only benefit would be the stacktrace generated which will anyway require enable-debug for further investigations. Anyway, I will add the --with-debug-symbols and remove -g3 from default.

Replying to dmisev:

Ok sounds good. --with-optimization is useful, I'm using this to set -O0 during development. I'd prefer to have a separate --with-debug-symbols, instead of relying on --enable-debug for -g3. In the RPMs for example we should use -g2 or -g3, then debug symbols packages are automatically created, so anyone that needs the symbols for debugging can just install these packages.

To sum it up, we have these changes:

  • default: -g0
  • --without-debug-symbols -> with-debug-symbols (sets -g2 or -g3, we should investigate the differences and decide which one is preferable)

comment:15 Changed 15 months ago by mdumitru

Seems you still need -g alongside -Og http://stackoverflow.com/questions/12970596/gcc-4-8-does-og-imply-g so best we have -Og -g3. We also need to check that -Og exists in clang as well.

comment:16 Changed 15 months ago by dmisev

debug symbols are not really useful if you use anything but -O3

I guess you meant -O0 here.

-Og doesn't seem to exist in clang, so maybe we just stick to -O0 in this case.

comment:17 Changed 15 months ago by mdumitru

Ok, let's come to a conclusion so George can implement this. I collected this outcome (feel free to modify):

  • --without-debug-symbols -> with-debug-symbols (sets g flag to -g3)
  • default: -O3 -g0
  • enable-debug: -O0 -g3

Agreeable to all?

comment:18 Changed 15 months ago by dmisev

Yes perfect.

comment:19 Changed 15 months ago by pbaumann

I'm fine with the overall approach, but let us be careful about flag semantics (and cross-dependencies!) and the --with and --enable etc. variety (see also ticket #1138).

comment:20 Changed 15 months ago by gmerticariu

  • Owner changed from mdumitru to gmerticariu
  • Status changed from new to assigned

comment:21 Changed 15 months ago by dmisev

Here are some statistics in compiling with make -j4 (the size, e.g. 53M, is the size of $RMANHOME):

configure rnp rasnet
--without-debug-symbols real 150.28
user 394.76
sys 10.70
53M
real 311.61
user 904.70
sys 33.07
131M
-g3 real 213.14
user 529.93
sys 18.98
752M
real 437.36
user 1188.92
sys 49.06
1.1G
--without-debug-symbols
(including git submodules)
real 613.65
user 1129.95
sys 47.35
131M

comment:22 Changed 15 months ago by pbaumann

this doesn't seem correct in the patch:

+ [AS_HELP_STRING([--with-debug-symbols],

[compile rasdaman without debug symbols])],

comment:23 Changed 15 months ago by gmerticariu

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.