Excluding Small Functions From Instrumentation
In Visual Studio 2008, we added a feature to exclude small functions from instrumentation. A small function is a function that has very few instructions and makes no function calls (i.e. it’s a leaf). The idea behind this feature is that small functions are unlikely to be significant in the overall profile of your application, so we can skip collecting data for them altogether to avoid the overhead of otherwise doing so. This feature is meant to exclude property getters and setters, but it will also exclude very simple functions that are typically inlined anyway.
The first benefit of this feature is reduced instrumentation probe execution overhead. Typically, small property getters and setters incur the time cost of executing two probes: the enter and exit probes. The execution time of these probes dwarfs the execution time of the getter or setter itself. To top it off, this cost is paid on every single property access which can be frequent. By not instrumenting these property getters and setters, we can reduce execution overhead.
The second benefit is reduced profile data file (.vsp) size. Fewer probes means less data collected. If you’ve done instrumentation profiling before, you probably know that the data files can grow quickly. Keeping file sizes smaller facilitates sharing and faster analysis.
The third benefit is reduced noise in your profile. Since we don’t collect any data for these insignificant functions, they won’t even show up in your reports. This is similar to, but independent of, the new noise reduction feature in VS2008.
With this feature enabled, it’s important to note that the time spent executing a small function does not just disappear. Instead, the time gets attributed to the callers of the function excluded. For example, if Foo calls SmallFunc, the exclusive time of SmallFunc when Foo called it is added to Foo’s exclusive time. It’s as if the function was inlined at all of its call sites.
Small function exclusion is enabled by default which can, on occasion, cause issues. Really simple projects such as a default C# console application or a default WCF service, are essentially infrastructure code in addition to (nearly) empty functions. Because of this, profiling one of these default project types immediately after creation will typically yield “Error VSP1734 : File contains no data: ...” since nothing gets instrumented (they’re all small functions, after all).
You can disable small function exclusion by opening an instrumentation target’s properties, selecting the Instrumentation section, and unchecking “Exclude small functions from instrumentation”. Each instrumentation target has its own value for this property.
If you’re instrumenting your binaries on the command-line using vsinstr.exe, you can specify /excludesmallfuncs to exclude small functions from instrumentation. The default command-line behavior is to instrument everything.