---
title: Slow snap? Trace-exec to the rescue!
description: Slow applications are never fun. But not knowing why an application is
  not behaving correctly can be even more frustrating. A well-designed system that
  can diagnose performance or startup issues and inform the user about the problem
  goes a long way toward mitigating the frustration, and may even help resolve the
  root cause altogether. Bac […]
url: https://canonical.com/blog/slow-snap-trace-exec-to-the-rescue?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Igor Ljubuncic](https://canonical.com/blog/author/igorljubuncic "More about Igor Ljubuncic")

8 August 2019

# Slow snap? Trace-exec to the rescue!

[Debugging](https://canonical.com/blog/tag/debugging)
[Development](https://canonical.com/blog/tag/development)
[snapcraft.io](https://canonical.com/blog/tag/snapcraft-io)
[strace](https://canonical.com/blog/tag/strace)
[trace-exec](https://canonical.com/blog/tag/trace-exec)
[troubleshooting](https://canonical.com/blog/tag/troubleshooting)

---

Share the article

Slow applications are never fun. But not knowing why an application is not behaving correctly can be even more frustrating. A well-designed system that can diagnose performance or startup issues and inform the user about the problem goes a long way toward mitigating the frustration, and may even help resolve the root cause altogether.

Back in January, we reviewed several tools used to [troubleshoot snap usage](https://snapcraft.io/blog/snap-up-your-development-tools-for-making-the-snap-trek-easier), including the strace functionality built into the snap binary. However, strace requires some knowledge of system internals, so it may not be the first choice for users or developers looking to quickly diagnose and profile the behavior of their snaps. From version 2.36 onwards, snapd ships with the *–trace-exec* run option. This convenient and friendly feature lists the slowest processes in the snap startup and runtime chain, which can help you pinpoint the source of the issue.

# Trace-exec in action

Technical troubleshooting is like an onion – layered and complex. Which is why you always start with simple things first. Going back to strace, if you want to profile the execution of an application, you can run strace with the *-c* (summary) flag. This will give you the list of all the system calls, the percentage of CPU time spent in each, average time per system call, errors, and several other important details. At first glance, this can be a useful indicator, but it requires a keen eye, and the data is not shown on a per-process level.

Trace-exec offers a terser output, listing up to 10 *slowest* processes that ran and finished during the run of a snap. Typically, this will include the actual snap startup and some portion of its runtime. While not as comprehensive as strace, it can give you a good overview of all the commands, command wrappers and helper scripts used to bootstrap the snap.

Let’s look at a practical example with the [VLC](https://snapcraft.io/vlc) media player.

```
snap run --trace-exec vlc
```

```
Slowest 10 exec calls during snap run:
  0.007s snap-update-ns
  0.088s /snap/core/7270/usr/lib/snapd/snap-confine
  0.006s /usr/lib/snapd/snap-exec
  0.007s /usr/bin/getent
  0.006s /bin/mkdir
  0.006s /bin/mkdir
  0.007s /bin/mkdir
  0.160s /snap/vlc/1049/bin/desktop-launch
  0.035s /snap/vlc/1049/usr/bin/glxinfo
  0.042s /snap/vlc/1049/bin/vlc-snap-wrapper.sh

Total time: 2.295s
```

From this run, we can see that a portion of time is dedicated to the snap setup, like the confinement. You also get the total time – but part of this number may also be the actual time the application runs, so it is not strictly the startup portion of the entire sequence. Nevertheless, it is a useful indicator, and we’ve discussed this in much greater detail in the [I have a need, a need for snap](https://snapcraft.io/blog/i-have-a-need-a-need-for-snap) article some time ago.

On its own, of course, the information will not resolve the problem – but it can be used by snap developers and application developers to optimize their tools. For instance, an enhancement or a big fix could be implemented into snapd, or perhaps a developer may realize that certain libraries staged into the snap contribute the highest penalty to the startup and behavior of their software.

In comparison, with strace, you would see the following:

```
snap run --strace='-c' vlc
```

```
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ------------
 53.40    4.041220        3419      1182         1 poll
 34.21    2.589384        2281      1135        30 futex
  4.87    0.368380         251      1466        81 read
  4.61    0.348855        2474       141        56 wait4
  1.09    0.082512          15      5607      4457 open
  0.55    0.041282       41282         1           rt_sigtimedw
  0.36    0.027104           4      6200      2616 stat
  0.09    0.006461           3      2536           mprotect
  0.08    0.006255          20       316           getdents
  0.08    0.006148           8       740       490 access
  0.07    0.005506           3      1853         6 close
…
  0.00    0.000000           0         2           capset
  0.00    0.000000           0         1           prlimit64
------ ----------- ----------- --------- --------- ------------
100.00    7.568409                 31057      7960 total
```

This output is not for the faint-hearted. You have no instant visibility into which processes contributed to which system call, and you also need some understanding of what each system call means. If you want to know more, you can always use the man 2 pages to learn more about specific calls, e.g.:

```
man 2 mprotect
```

# Summary

Trace-exec complements other troubleshooting features in snapd quite nicely. Alongside other assets in the snap ecosystems, it provides developers as well as users with means to better understand why sometimes their applications do not always perform quite as they should.

This valuable information, when available, also allows the snap teams to implement fixes and changes that will make the overall snap experience smoother and more enjoyable. If there are other features or capabilities you’d like to see introduced in snapd, please let us now by joining our [forum](https://forum.snapcraft.io/) for a discussion.

Photo by [Marten Bjork](https://unsplash.com/@martenbjork?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText).

[Get in touch

Interested in running Ubuntu in your organization?](https://ubuntu.com/about/contact-us/form)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### Snapcraft 8.0 and the respectable end of core18](https://canonical.com/blog/snapcraft-8-0-and-the-respectable-end-of-core18)

‘E’s not pinin’! ‘E’s passed on! This base is no more! He has ceased to be! ‘E’s expired and gone to meet ‘is maker! ‘E’s a stiff! Bereft of life, ‘e rests in peace! If you...

[Igor Ljubuncic](https://canonical.com/blog/author/igorljubuncic)

16 June 2023

[### Creating Snaps on Ubuntu Touch](https://canonical.com/blog/creating-snaps-on-ubuntu-touch)

This article was written in collaboration with Alfred E. Neumayer of the UBports Project. Tablets, phones and current technology’s capabilities are phenomenal. Who would have...

[Aaron Prisk](https://canonical.com/blog/author/aaronprisk)

3 April 2024

[### Crafting new Linux schedulers with sched-ext, Rust and Ubuntu](https://canonical.com/blog/crafting-new-linux-schedulers-with-sched-ext-rust-and-ubuntu)

In our ongoing exploration of Rust and Ubuntu, we delve into an experimental kernel project that leverages these technologies to create new schedulers for Linux. Playing around...

[arighi](https://canonical.com/blog/author/arighi)

26 February 2024

[### Managing software in complex network environments: the Snap Store Proxy](https://canonical.com/blog/managing-software-snap-store-proxy)

As enterprises grapple with the evolving landscape of security threats, the need to safeguard internal networks from the broader internet is increasingly important. In...

[Holly Hall](https://canonical.com/blog/author/hollyhall)

15 January 2024
