Profiling COM Logical Threads

Applies to AQTime 8.81, last modified on January 18, 2022

A COM server may receive several requests from client applications simultaneously. To profile such a situation correctly, the Allocation, BDE SQL, Coverage, Function Trace, Performance, Reference Count and Resource profilers include a Thread model option that should be set to COM threads. This topic explains why this is needed.

Suppose, you profile a COM server with two client applications (see the figure below):

Client A calls the server function F1. Suppose, this function executes for a long time (As shown on the figure above, the function is displaying a message box. So, it will execute until a user closes this message box). Now imagine that another client application, Client B, calls the server function F2, which finishes earlier than F1 (because the message box has not been closed).

Both functions can be executed in the same Windows thread. “This is the default implementation of the COM servers with the Apartment threading model. COM servers with other threading models can also process several client requests within the same thread.” you will probably say. The problem is that since F2 starts and finishes during the F1 execution and both functions are run within the same thread, the Performance profiler “thinks” that F2 is a child function of F1. This leads to inaccurate profiling results: the execution time of the F2 function is added to the time-with-children value of F1, the Details, Call Graph and Call Tree panels display F2 as a child of F1, etc.

Setting the Thread model option to COM threads solves the problem. After you specify this value, AQTime will perform additional check to determine the “relationship” of the COM server functions. This helps avoid getting inaccurate profiler results. Note, however, that the additional check takes some time. If the profilers always did this check, the profiling speed would be slower. You should use the COM threads value if you profile a COM server with several clients, or if several threads in the same client application include server function calls. The COM server threading model (apartment, single, etc.) is of no importance. The only factor that specifies whether you should use this value is the number of clients.

See Also

Profiling COM Applications
Profiling Multiple Threads

Highlight search results