@SGaist that’s a great blog post, thanks!
@JonB: thank you for your suggestions. There’s not very much different from a Qt-app point of view about Linux running on an embedded device vs on the Desktop so your experience is certainly relevant. You are correct, the environment is much more deterministic: startup is via sysvinit rather than full-fledged systemd, and the user space is stripped-down and does not use X (the Qt app runs fullscreen at boot using the EGLFS platform plugin). There are very few processes running on the system; idle mem usage (without my app running) is under 20 MB. This is why the inordinate startup delay was rather unexpected.
To answer your questions:
has whatever "UI initialization" been done?
There are no “UI-things” that need to be performed. System boots, kernel starts the init process (PID 1) that executes startup shell scripts in /etc/init.d which start logging daemons, network, sshd. The last thing to get started is my Qt app. If the app were left out, the system would just boot and do nothing, with only the framebuffer boot logo displayed on the screen.
Can you write a non-UI Qt app and compare that for its first/second time run timings?
What happens if you do the first/second runs of your app not at boot-time?
I did indeed write a Hello World Qt console app to test. It did reveal an interesting (but definitely-not-pertinent-to-Qt) detail that I left out in my initial message: there is an unknown interaction with app startup and the kernel random number generator device. The HelloW app runs in basically no time at all normally. But when launched via an init script, it takes 5 seconds to run! Turns out that is when the random number init is not yet complete. Once that is complete (the random-device driver prints “crng init done” in dmesg), all times are repeatable. It is these times that I have reported in my original message -- not exactly at boot, but after the rng init is complete (so that the as-yet undetermined effect of the rng is taken out of reckoning). In this case I launch the app from the console, not from the init script.
Does your Pi-Linux have strace? Hope so! Use that
This is useful, thanks. The link that @SGaist provided uses LTTng which appears to be strace-on-steroids. Unfortunately it doesn’t seem like it will be a quick resolution, so I will update this thread once I get to the bottom of it.
Thank you both for your time!