Low performance when using DriverWorks

Hi,

We have a project to rewritte code of our Win2K Drivers (written in C)for
PCI card to WDM Drivers using DriverWorks. A lot of code has been reused.
Only the front end is big different. The old one is in C and the new one
in C++ using DriverWorks template. The project is half completed.
Now we experienced a big drop of performance (4-5 times slower) in new
Drivers versus the old one.

To narrow down the problem. I’ve tried to compare the time it takes to
process a IOCTL in both drivers.

I used DriverWorks wizard to created a new sample WDM driver for PCI card
(do not have any of my old driver code)

I used the following sample code in an application to calculate the time
it takes to process one dummy IOCTL ( When receive the request from Kernel
driver, the Irp is completed right away without doing anything )

QueryPerformanceCounter(&Before);

DeviceIoControl( hDriver, IOCTL_DUMMY_TEST, … );

QueryPerformanceCounter(&After);

With a sample WDM Driver created by DriverWorks wizard,
It takes about ~0.210 ms

With a sample Win2k driver that I wrote using C
it takes only ~50 microssecond.

I have tried with both DriverWorks Debugbuild and Release build. The
Release build is a bit faster but it still in the odrder of 0.200ms

Anyone who used DriverWorks, have you timed the similar IOCTL and
experience the same thing as I did ?

I expect a little overhead with C++ but not that much.

The overhead is because of C++ or because of DriverWorks ??

Is there any thing I can do with DriverWorks to improve performance
(compiler setting etc …)

I posted the question to Compuware Tech support but do not yet receive
the answers. I want to hear from you, the experts and the ones have much
experience with C++ and DriverWorks.

Both drivers are build uisng MSVC 6.0 and Win2K DDK

Please help,

QUANG

If you have DriverStudio, you can turn on TrueTime, it should be able to
tell you where the bottlenecks are.

Alberto.

-----Original Message-----
From: Quang Vu [mailto:xxxxx@gage-applied.com]
Sent: Friday, May 23, 2003 10:39 AM
To: NT Developers Interest List
Subject: [ntdev] Low performance when using DriverWorks

Hi,

We have a project to rewritte code of our Win2K Drivers (written in C)for
PCI card to WDM Drivers using DriverWorks. A lot of code has been reused.
Only the front end is big different. The old one is in C and the new one
in C++ using DriverWorks template. The project is half completed.
Now we experienced a big drop of performance (4-5 times slower) in new
Drivers versus the old one.

To narrow down the problem. I’ve tried to compare the time it takes to
process a IOCTL in both drivers.

I used DriverWorks wizard to created a new sample WDM driver for PCI card
(do not have any of my old driver code)

I used the following sample code in an application to calculate the time
it takes to process one dummy IOCTL ( When receive the request from Kernel
driver, the Irp is completed right away without doing anything )

QueryPerformanceCounter(&Before);

DeviceIoControl( hDriver, IOCTL_DUMMY_TEST, … );

QueryPerformanceCounter(&After);

With a sample WDM Driver created by DriverWorks wizard,
It takes about ~0.210 ms

With a sample Win2k driver that I wrote using C
it takes only ~50 microssecond.

I have tried with both DriverWorks Debugbuild and Release build. The
Release build is a bit faster but it still in the odrder of 0.200ms

Anyone who used DriverWorks, have you timed the similar IOCTL and
experience the same thing as I did ?

I expect a little overhead with C++ but not that much.

The overhead is because of C++ or because of DriverWorks ??

Is there any thing I can do with DriverWorks to improve performance
(compiler setting etc …)

I posted the question to Compuware Tech support but do not yet receive
the answers. I want to hear from you, the experts and the ones have much
experience with C++ and DriverWorks.

Both drivers are build uisng MSVC 6.0 and Win2K DDK

Please help,

QUANG


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

DriverWorks will not add that amount of overhead to your driver. C++ will
not add that amount of overhead to your driver.

I used my favorite performance analyzer TrueTime Driver Edition from
DriverStudio to examine 3 drivers (free builds):

  1. portio from the W2k DDK.
  2. portio from DriverWorks. This driver is basically the same driver as 1
    plus c++ and usage of a few DriverWorks utility classes. (c++ as a better
    c while maintaining DDK procedural driver design)
  3. portio from DriverWorks that does use the entire DriverWorks c++
    framework.

Each driver handles IOCTLs to preform port io and has a corresponding test
app.
After analyzing the drivers, the time to complete an IOCTL to read a byte
from a port where the following:

  1. Avg time to complete = 0.0025 ms
  2. Avg time to complete = 0.0026 ms
  3. Avg time to complete = 0.0022 ms (note that this ioctl handler has
    different, more efficient code)

The conclusion is that careful C++ coding adds neglible overhead (1/25) to
your driver. DriverWorks also adds minimal overhead to your driver.

The real performance issues have to do more with proper driver design to
minimize ring transitions and issues dealing with I/O bound nature of
drivers. Typical drivers are I/O bound and not CPU bound. So C++ doesn’t
hurt.

As for your problem, are you porting an NT kernel-mode legacy driver to
WDM? If that’s the case, the WDM driver must implement a plug and play
and power management state machine that impacts processing of IRP’s.
DriverWorks framework provides such state machines. A dummy IOCTL handler
will still process the plug and play and power managment state machine in
a WDM driver. This could explain some performance hit vs a legacy driver.

Please go thru Compuware Tech Support for more help on this issue.

I hope this helps.

Steve Smith
Compuware Corp.