Chapter 2

  1. What does it really mean when Apitrace preloads an instrumented implementation of OpenGL? 
    This means exactly what is said here—Apitrace provides a DLL-implementing OpenGL functionality, which contains their tracing code. Preloading is a technique for loading a library manually, before the operating system has a chance to do so.
  2. Isn't there a way to use gprof after all?
    Yes, of course. Just don't use threads, and link everything statically. You just have to add the appropriate switch (-pg) to qmake's compiler and link options, and maybe add gprof as external too.
    For simpler projects, this could perhaps be an option, but simpler projects normally don't have many performance problems, and if they do, a quick evaluation with Process Explorer would probably disclose their causes.
  1. How would you look for a lock convoy or a waiting chain causing your UI to stutter or, even worse, to freeze?
    Use some tooling—either a specialized commercial tool such as Intel Inspector, or the Windows all-purpose weapon, WPF (it could be that you have to read some more of Bruce Dawson's blogs if you do).
  2. What is the difference between CPU Usage (Precise) and CPU Usage (Sampled) in ETW traces?
    CPU usage (precise) is obtained from kernel events recording context switches; CPU usage (sampled) comes from sampling data and is thus less precise, as we already mentioned in the discussion of profiler types.
  3. How would you find timers running amok or QML items accumulating video memory?
    You could use KDAB's GammaRay tool for that. Refer to its discussion to see how.
  4. What can you do when your favorite open source performance is not supported by Qt Creator?
    Qt Creator is open source, so you either hack the support directly into your copy, or you do something for the community and write a Qt Creator plugin for that tool.
  5. What is that thread and lock analysis feature some of the tools seem to have?
    Some tools can show you which thread ran when and on which processor core. Lock analysis comprises at least a visualization of currently held locks and their dependencies.
  6. If you try to launch the example program directly or from some external CPU profiler, this won't work. Why? How would you fix it?
    You have to let the system know where both Qt's and MinGW's DLLs are stored so it is able to load them. This is done by setting the appropriate paths in Windows PATH environment variable.
  7. If we don't use any custom ETW events in our program, will we be able see any information about the program in ETW traces?
    Yes, we will see all the kernel calls our program issues, its CPU profile, context switches, keyboard inputs, and so on.
  8. Which one is better—sampling or instrumentation?
    This was a trick question! Did you fall for it? Both are good.