Search code examples
c++optimizationcom

What does RtlInitializeExceptionChain do, and how can I reduce its execution overhead?


I am trying to find bottlenecks in my program (currently in the "low-hanging fruit" stage), and using a profiler I get something like the following:

Sleepy screenshot

The thing I see in this is that RtlInitializeExceptionChain takes up the far majority of the time, and functions from my actual program don't even make it onto this top list. I would like to know if anyone knows what RtlInitializeExceptionChain does, how it is called, and how I can reorganize my program to not call it so much?

Some other information about my project: it is a COM API using ATL, and the program being profiled is a "testing" C++ program which consumes this API.

Thanks!


Solution

  • RtlInitializeExceptionChain is an internal function in the Run-Time Library, a collection of kernel-mode support functions used by kernel-mode drivers and the OS itself. It's kind of the kernel-mode version of the C run-time library.

    If your application is 32-bit and you're profiling it on a 64-bit machine, profiling it on a 32-bit machine or building a 64-bit version will probably move RtlInitializeExceptionChain out of the top 10 list since it's always used in thunking.

    Otherwise, there's almost certainly nothing you can do about it.