Author Topic: [QUESTION] How to profile application?  (Read 2474 times)

the_gama (OP)

  • *
  • Posts: 155
[QUESTION] How to profile application?
« on: September 03, 2013, 08:46:46 pm »
Hi, I found this link (http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html) and wanted to test gprof with the app I'm porting, to see if I can optimize it. As stated in the tutorial, I have added the -pg flag to both the compiler and linker, and removed all optimizations.  But I'm getting the following error:

Code: [Select]
/opt/gcw0-toolchain/usr/lib/gcc/mipsel-gcw0-linux-uclibc/4.8.1/../../../../mipsel-gcw0-linux-uclibc/bin/ld: cannot find gcrt1.o: No such file or directory
collect2: error: ld returned 1 exit status

I can't seem to find such file in the toolchain, but maybe I missed it.  What is the correct way to use gprof with opendingux?

Thanks in advance.

pcercuei

  • ***
  • Posts: 1428
    • My devblog
Re: [QUESTION] How to profile application?
« Reply #1 on: September 03, 2013, 09:04:57 pm »
gprof is for glibc only, while we use uClibc. However, you can use "oprofile", which is supported out of the box.

Via telnet / SSH, to setup oprofile:
Quote
opcontrol --init
opcontrol --setup --no-vmlinux
To start profiling:
Quote
opcontrol --start
To stop profiling:
Quote
opcontrol --stop
To get the results, first stop profiling, then type
Quote
opreport -l
It will give you the time spent in the functions of your program.

the_gama (OP)

  • *
  • Posts: 155
Re: [QUESTION] How to profile application?
« Reply #2 on: September 03, 2013, 09:14:35 pm »
Thank you very much pcercuei.  I suppose I need to build the application without any optimizitation flags right? 
Will test it ASAP.

What about gcov? Is it supported? Or is there any equivalent command?

[UPDATE]

Ok, started a telnet session and started typing the commands, but got the next error after opcontrol --setup:

Code: [Select]
mkdir: can't create directory '/root/.oprofile': Read-only file system
Couldn't mkdir -p /root/.oprofile
« Last Edit: September 03, 2013, 09:29:32 pm by the_gama »

pcercuei

  • ***
  • Posts: 1428
    • My devblog
Re: [QUESTION] How to profile application?
« Reply #3 on: September 05, 2013, 01:19:45 pm »
Ok, we fixed the error some days ago, but I forgot that it's still present on the latest public firmware.
To fix the issue, type this command first:
Code: [Select]
mount none -t tmpfs /root
Gcov/gprof are for glibc only, so you can't use those. But oprofile is just as powerful, and I'd even say it's better since you can profile the entire system: your program, the libs it uses, and the kernel. The only requirement for the program to profile is that you compile it with the -g flag, and that you don't strip the binary; you can profile it with the regular CFLAGS without problems.

the_gama (OP)

  • *
  • Posts: 155
Re: [QUESTION] How to profile application?
« Reply #4 on: September 05, 2013, 05:19:14 pm »
Thanks, I managed to run the scripts by copying them to the sdcard.  But will use the suggested command now.  I can't wait to see what features will be added to the next firmware update, any hint? ;).

BTW, I often chech the status of the vivante driver, and it seems it can already be built for beta testing, has anyone tested the driver?

the_gama (OP)

  • *
  • Posts: 155
Re: [QUESTION] How to profile application?
« Reply #5 on: November 06, 2013, 04:07:38 am »
Hi, I didn't want to create another thread, since this seems appropiate.  I have obtained the following results using the profiler script:

Code: [Select]
samples  %        app name                 symbol name
19861    40.8293  no-vmlinux               /no-vmlinux
9608     19.7517  egl_gallium.so           /usr/lib/egl/egl_gallium.so
3439      7.0697  genesis_plus_gx_libretro_gcw0.so YM2612Update
3153      6.4818  libuClibc-0.9.33.2.so    /lib/libuClibc-0.9.33.2.so
1729      3.5544  genesis_plus_gx_libretro_gcw0.so render_bg_m5
1282      2.6355  genesis_plus_gx_libretro_gcw0.so render_obj_m5
1265      2.6005  genesis_plus_gx_libretro_gcw0.so m68k_run
1132      2.3271  genesis_plus_gx_libretro_gcw0.so remap_line
746       1.5336  genesis_plus_gx_libretro_gcw0.so SN76489_RunUntil
735       1.5110  genesis_plus_gx_libretro_gcw0.so z80_run
706       1.4514  genesis_plus_gx_libretro_gcw0.so blip_add_delta
594       1.2211  retroarch-gcw0           resampler_sinc_process
200       0.4112  retroarch-gcw0           audio_flush.part.59
196       0.4029  genesis_plus_gx_libretro_gcw0.so fm_read
187       0.3844  genesis_plus_gx_libretro_gcw0.so parse_satb_m5
...

According to the table, 40% of cpu time is spent in the no-vmlinux, I believe that is the kernel right? Is there any way to get a more detailed information about which kernel calls are causing that result?  Could that be audio processing or maybe time waiting for vsync?


mth

  • *
  • Posts: 298
Re: [QUESTION] How to profile application?
« Reply #6 on: November 06, 2013, 04:36:23 am »
According to the table, 40% of cpu time is spent in the no-vmlinux, I believe that is the kernel right? Is there any way to get a more detailed information about which kernel calls are causing that result?

I don't know. Maybe you can point oprofile at a System.map for the kernel and see separate functions for the kernel too, but I've never tried that myself.

Could that be audio processing or maybe time waiting for vsync?

Unlikely: the kernel doesn't do much audio processing, all the heavy parts are done in user space instead, and waiting for vsync is done by letting the waiting process sleep, so it doesn't consume CPU time.

My first suspect would be the Vivante GPU kernel driver, since there seems to be a lot of GL action going on. Is there a way to profile without rendering anything? (I mean, disable all rendering in the app.) Then the difference in CPU usage should tell you whether it's from the GPU or something else.

 

Post a new topic