Analyze Driver PerformanceUpdated: March 2, 2004
Note: Kernrate is deprecated and will be removed from future releases of Windows. Instead, use the Windows Performance Analysis Tools. For more information, see the Windows Performance Analysis Developer Center. On This Page
This paper provides information about using Kernrate and KrView on the Microsoft Windows family of operating systems. Driver writers can use these tools to collect and analyze driver performance data. The first step towards improving any driver's performance is to analyze that driver's performance. If you don't know where your driver is spending time, you can't effectively tune it. In general, you should focus your tuning efforts on the most frequently exercised and most time-consuming code paths. One way to identify these areas is to gather data with Kernrate and analyze it with KrView.
Kernrate is a command-line tool that supports all Windows hardware architectures and runs on Windows 2000 and later versions. Kernrate is shipped with the Microsoft Windows Server 2003 Resource Kit. KrView is a companion tool that organizes the Kernrate data and displays it graphically in Microsoft Office Excel spreadsheets. KrView requires a version of Kernrate that supports the -yr option. Microsoft Excel must be installed on the computer on which you run KrView, but is not required on the computer on which you run Kernrate. (The current version of KrView requires Microsoft Office Excel XP or later. Support for Microsoft Office Excel 2000 is planned but is not yet available.) Profile Driver Performance Using KernrateBefore running Kernrate, make sure that you have the symbol table (.pdb file) for the current build of your driver. Kernrate uses the symbol table to map addresses to the names of individual functions. If possible, you should also have the symbol tables for any other modules your diver calls or is called by. Having these symbol tables lets you find out which functions are calling your driver the most and which external functions your driver uses. For example, if your driver frequently acquires system spin locks, the time spent in those locking functions will be assigned to the system functions associated with them, and not to your driver. After changing your driver, you can compare “before” and “after” profiles to see the effects in other modules as well as the direct effects in the driver itself. Kernrate can gather data on the entire system or on one or more specific processes, depending on the options you specify. It can also “zoom in” on one or more modules to generate detailed, function-level data. Kernrate divides the address space of each module into “buckets” and then records CPU event occurrences within each bucket. After profiling is complete, Kernrate translates the bucket addresses into symbols. Using KrView, you can see how much CPU time each function in the module consumed. To get an accurate picture of driver performance, consider profiling in stages:
As you identify potential performance issues, try running Kernrate on a variety of test machines and with a variety of hardware and software configurations. Performance characteristics can change significantly from system to system because of interactions among components. What looks like a bottleneck in one configuration might disappear in another. As a general rule, the more data you gather, the clearer picture you'll have of how your driver performs. Use KrView's comparison feature to compare profiles made on different test configurations. Kernrate has numerous options that control the extent and detail of the generated profile. (For a complete list, see the Kernrate documentation.) Options that are particularly useful in profiling drivers are listed below.
Use a command line like the following to gather a baseline system profile on a multiprocessor system: kernrate -v 3 -b 4 -f -m -ts -yr baseline.kv This command runs Kernrate on a multiprocessor system and:
After you create the baseline profile for the system, you can use a command line like the following to zoom in on modules within your driver: kernrate -v 3 -b 4 -f -m -ts j "c:\mydriver\symbols" -yr driverbase.kv -z driverio -z driverpnp -z driverwmi This command line causes Kernrate to gather the same profile data as the preceding example. In addition, it looks for the symbol table for the driver in the directory c:\mydriver\symbols and gathers detailed data for the modules “driverio,” “driverpnp,” and “driverwmi” that are loaded by the system. Analyze Kernrate Data Using KrViewAfter you collect Kernrate data, you can use KrView to analyze it. KrView can display data from a single Kernrate sample or can compare up to 64 Kernrate samples at once. KrView consists of an Excel workbook that defines macros for organizing and displaying Kernrate data. The KrView installation program adds the KrView toolbar to the Excel interface; you can then run KrView by either clicking on the KrView toolbar icon within Excel or by opening the KrView.xls workbook. The KrView.xls workbook sets defaults that apply each time you run KrView. When you process a Kernrate output file, KrView creates a new workbook that contains the processed data. The number and contents of the worksheets in the workbook depend on the options you specified when you ran Kernrate. Suppose you run Kernrate with the command line shown in the preceding example: kernrate -v 3 -b 4 -f -m -ts j "c:\mydriver\symbols" -yr driverbase.kv -z driverio -z driverpnp -z driverwmi When KrView processes the input file driverbase.kv, it creates an Excel workbook named driverbase_KrView.xls by default. The workbook includes worksheets that summarize module data for both user-mode and kernel-mode (privileged) modules and for the top “hot” (that is, most CPU-intensive) modules in the profile. If the profile covers more than one CPU, as in the example, each of the summary worksheets includes a Per CPU Detail button. Click this button to show CPU usage split out by CPU number. For driver writers, the individual worksheet for each zoomed module is of primary interest. In this example, these worksheets are named Driverio, Driverpnp, and Driverwmi. Each displays the percentage of CPU time used by functions in that module. By choosing from the drop-down menu at the upper right on one of these worksheets, you can change the number of functions shown in the chart. You can also use the pivot tables below the chart to add or remove data for individual functions or CPUs from the chart. Clicking on Raw Data at the top of any chart displays the raw profiling data used to build the chart. You can use this information to determine if the profile size is adequate. If you see that a function takes much less CPU time than you expected, check the number of hits reported in the raw data. If the number of hits is relatively small, you might try changing the sampling rate to get a more adequate profile. You might also try running the profile with a different mix of applications. Note Best Practices for Using Kernrate and KrView
Download KrView and KernrateDownload KrView, the latest version of Kernrate, and the documentation for both tools from KrView - the Kernrate Viewer. This download package includes versions of the Kernrate executable for Windows 2000 and both the 32-bit and 64-bit versions of Windows XP. KrView is a new tool, and Microsoft encourages your feedback and suggestions. To respond, send email to krview@microsoft.com. Other Performance Analysis Tools
|
|

