DPC latency

Hi,

DPC latency increases significantly when you use the following programs:

#include <windows.h>
#include <stdlib.h>
#include <stdio.h>

void openCloseH()
{
unsigned long result;
HWAVEOUT outHandle;
WAVEFORMATEX waveFormat;

/* Initialize the WAVEFORMATEX for 16-bit, 44KHz, stereo /
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
waveFormat.nChannels = 2;
waveFormat.nSamplesPerSec = 44100;
waveFormat.wBitsPerSample = 16;
waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSample/8);
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
waveFormat.cbSize = 0;

/
Open the preferred Digital Audio Out device. Note: myWindow is a handle to some open window /
result = waveOutOpen(&outHandle, WAVE_MAPPER, &waveFormat, 0,0,CALLBACK_NULL);
if (result)
{
printf(“There was an error opening the preferred Digital Audio Out device!\n”);
}

// close the wav device
if (waveOutClose(outHandle) != MMSYSERR_NOERROR)
{
printf(“Sound card cannot be closed!\n”);
}
}

void main(int argc, char
* argv)
{
int count = 1000;
if(argc > 1) {
int tmp = atol(argv[1]);
if(tmp > 0 ) count = tmp;
}

for(int i = 0; i {
openCloseH();
printf(“Open/close %d\n”, i);
}
}
-----------------------------------------------
And the latency increases as the number of processors, worst result was a computer with Core I7 (enable all cores). I ask all to see this effect with dpclat.exe, but the same results are obtained xperf.

Any comments?</stdio.h></stdlib.h></windows.h>

So what? There’s the sound driver responsible for this. Try on another
machine.
– pa

wrote in message news:xxxxx@ntdev…
> Hi,
>
> DPC latency increases significantly when you use the following programs:
> -----------------------------------------------
> #include <windows.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> void openCloseH()
> {
> unsigned long result;
> HWAVEOUT outHandle;
> WAVEFORMATEX waveFormat;
>
> /* Initialize the WAVEFORMATEX for 16-bit, 44KHz, stereo /
> waveFormat.wFormatTag = WAVE_FORMAT_PCM;
> waveFormat.nChannels = 2;
> waveFormat.nSamplesPerSec = 44100;
> waveFormat.wBitsPerSample = 16;
> waveFormat.nBlockAlign = waveFormat.nChannels *
> (waveFormat.wBitsPerSample/8);
> waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec *
> waveFormat.nBlockAlign;
> waveFormat.cbSize = 0;
>
> /
Open the preferred Digital Audio Out device. Note: myWindow is a handle
> to some open window /
> result = waveOutOpen(&outHandle, WAVE_MAPPER, &waveFormat,
> 0,0,CALLBACK_NULL);
> if (result)
> {
> printf(“There was an error opening the preferred Digital Audio Out
> device!\n”);
> }
>
> // close the wav device
> if (waveOutClose(outHandle) != MMSYSERR_NOERROR)
> {
> printf(“Sound card cannot be closed!\n”);
> }
> }
>
> void main(int argc, char
* argv)
> {
> int count = 1000;
> if(argc > 1) {
> int tmp = atol(argv[1]);
> if(tmp > 0 ) count = tmp;
> }
>
> for(int i = 0; i> {
> openCloseH();
> printf(“Open/close %d\n”, i);
> }
> }
> -----------------------------------------------
> And the latency increases as the number of processors, worst result was a
> computer with Core I7 (enable all cores). I ask all to see this effect
> with dpclat.exe, but the same results are obtained xperf.
>
> Any comments?
></stdio.h></stdlib.h></windows.h>

We have checked all the computers available to us on them are different OS (from WinXP to Win7). In carrying out this program latency increases from 2 to 10 times. I wonder what the effect will be on your machine?

Hey great, I’d LOVE to do some testing for you. Whom do I invoice? My rate
is hourly and I bill a minimum is 8 hours.

Gary G. Little
H (952) 223-1349
C (952) 454-4629
xxxxx@comcast.net

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@rambler.ru
Sent: Thursday, June 24, 2010 8:21 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] DPC latency

We have checked all the computers available to us on them are different OS
(from WinXP to Win7). In carrying out this program latency increases from 2
to 10 times. I wonder what the effect will be on your machine?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

wrote in message news:xxxxx@ntdev…
> We have checked all the computers available to us on them are different OS
> (from WinXP to Win7). In carrying out this program latency increases from
> 2 to 10 times. I wonder what the effect will be on your machine?
>

On my machine - no noticeable effect.
Gigabyte board with ICH9, Core2, Intel HD audio, G31 video, SATA.
Average latency is ~ 50 us, with peaks up to 600 us, max = 800 us.
– pa

xxxxx@rambler.ru wrote:

DPC latency increases significantly when you use the following programs:

The likely explanation is that your wave audio driver has called
timeBeginPeriod to increase the timer interrupt rate. That increases
the system overhead measurably, as you have seen. If you don’t want to
pay the penalty, don’t use audio.

Interesting how this would arrive while we are talking about the reasons
why Windows might not increase the USB interrupt rate.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I’d attribute it to a lousy soundcard driver, or a louse lower level driver under it. Also, if there are DPCs with LowImportance being queued, this may show excessive latency, because they are not executed immediately.

@Tim Roberts,
Regarding interrupt rate, tens of thousands interrupts per second per processor don’t seem to bring the modern processors to the knees. One thousand ips is just noise.

Thank you for your answers.
We performed another series of experiments. The most evident effect of increasing the DPC latency appears on a computer with Core i7 (intel dp55wg, windows 7). We used the built-in sound card and 2 other sound card.
Here are the results:
(1) The results did not depend on your sound card.
(2) The results do not depend on the timer resolution.
(3)As we have already pointed out the results depend only on the number of cores.
8 cores - 1850 microsec
4 cores - 1000 microsec
2 cores - 500 microsec
1 core - 385 microsec (more or less acceptable to us)
Here’s screen shot from that computer (8 cores): http://img153.imageshack.us/img153/5179/corei7w7.jpg

The DPC latency checker works by firing a kernel timer with an associated
DPC routine and measures the time between them. So what this number gives is
how much timer DPCs are suffering from latency that could be caused by
anything (other DPCs, ISRs, pagefaults).

You said you received same results from XPERF, but if you use the latest
version (run XPERF -on LATENCY) and you turn on symbol resolution you will
get exact execution times of each DPC routine, ISR and pagefault so that you
will see exact;y where and when each CPU is spending its time. That will
allow you to draw better conclusions.

There is an article in the latest OSR insider on using XPERF.

//Daniel

wrote in message news:xxxxx@ntdev…
> Thank you for your answers.
> We performed another series of experiments. The most evident effect of
> increasing the DPC latency appears on a computer with Core i7 (intel
> dp55wg, windows 7). We used the built-in sound card and 2 other sound
> card.
> Here are the results:
> (1) The results did not depend on your sound card.
> (2) The results do not depend on the timer resolution.
> (3)As we have already pointed out the results depend only on the number of
> cores.
> 8 cores - 1850 microsec
> 4 cores - 1000 microsec
> 2 cores - 500 microsec
> 1 core - 385 microsec (more or less acceptable to us)
> Here’s screen shot from that computer (8 cores):
> http://img153.imageshack.us/img153/5179/corei7w7.jpg
>
>

Yes, we used xperf (4.6.7231) from the latest SDK. But the results do not allow unambiguously determine the cause of the problem. Sometimes the delay is down upon usbport.sys, sometimes ndis.sys. But absolute value of the delay has always been one and the same (1.8 ms). We hypothesized that the delay falls on a random driver. Perhaps the delay associated with a shift in the OS mode multimedia?
If the open stream to the audio card already exists in the system, then this test does not lead to an increase in DPC latency. Because the system that does not create a new stream, and joins the existing one. This may explain the absence of this effect on some machines.
This test is not completely artificial, if we replace waveOutOpen / waveOutClose to PlaySound, you can get the behavior of normal windows control with validator.

Strikingly, xperf shows a similar latency and at ISR.

>Strikingly, xperf shows a similar latency and at ISR

This is either xperf artifact, or the processor power management artifact.