Lttng performance measurement

Hi, I am trying to measure performance by adding some code.
My target firmware version is 3.4.
And, I put perf code as follows.

  1. perf_alloc
  • When AP_Scheduler is initialized
  • _perf_XX = hal.util->perf_alloc(AP_HAL::Util::PC_ELAPSED, perfid);
  • As a example of perfid, it was “1” “2” and so on
  1. perf_begin
  • In AP_Scheduler::run function, I put it before each task start (before “_tasks[i].function()” this code)
  1. perf_end
  • After each task ends (_tasks[i].function();), I put it.

However, I cannot see any results.

I followed the guildline here
And I installed related libraries.

However, when I reboot the board, I could see only
pi@navio: ~$sudo lttng list --userspace
-> UST events:

w/o sudo it is same.

Since I am not sure about “ardupilot” in the below.
lttng enable-event --userspace ardupilot:count
lttng enable-event --userspace ardupilot:end
lttng enable-event --userspace ardupilot:begin

I changed it into “0” or “1” since I put that name when I call perf_alloc

In addition, I cannot see any results even with SCHED_DEBUG parameter setting which must show some results I believe.

Is there any person who have experience with lltng on NAVIO2?

Thank you

PS. Note that I also tried all lltng commands with sudo since ardupilot runs on root privilege. But, I couldn’t see any difference.

By default ArduPilot is not linked to lttng. You can install liblltng dev packages on the Raspberry itself and build ArduPilot there. Make sure that waf configure --board=navio2 states that lttng is detected and linked to. That is the easy but slow way.

Another approach is not for faint-hearted. We’ll cross-compile ArduPilot on a Linux host against the sysroot with the g++ wrapper that’s properly symlinked like this:


exec arm-linux-gnueabihf-g++.real --sysroot=$SYSROOT "$@"

SYSROOT is the environment variable to a mounted rootfs from Raspberry Pi with all the needed libraries.

So it all boils down to this:

  1. Grab our image and save it to $IMAGE_FILE and extract
  2. sudo kpartx -av $IMAGE_FILE to make a loopback device
  3. sudo mount /dev/mapper/loopXp2 rootfs to mount it
  4. systemd-nspawn -b --bind /usr/bin/qemu-arm-static -D rootfs to boot the image. Make sure binfmt module is loaded
  5. Now you have an emulated with qemu Raspberry Pi where you can poke around.
  6. sudo apt-get install liblttng dev packages inside the container
  7. Quit the container

After this steps you’ll have a rootfs with all libraries you need
8) Point SYSROOT to rootfs directory
7) waf configure --board=navio2 on your host should now detect liblltng and link against it.

You should see a message every once in a while in your GCS after you set it.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.