What causes poor network performance when playing audio or video in Windows Vista and newer?

This software is a native C ++ / MFC application that receives a large amount of data via UDP, and then processes the data for display, audio output and writing to disk, among other things. I first encountered a problem when the help document for the CHM application was launched from the help menu, and then I clicked on the help document when collecting data from the hardware. To repeat this, the AutoHotkey script was used to quickly click in the help document while the application was running. As soon as any sound occurred in the system, I began to receive errors.

If my sound card is completely disabled, everything works fine, without errors, although the sound output is clearly disabled. However, if I have a sound game (in this application, another application, or even just an audio signal from a message box), I get thousands of dropped packets (we know this because every packet has a timestamp). As a second test, I did not use my application at all and just used Wireshark to control incoming packets from the hardware. Of course, whenever sound was played in Windows, we dropped packets. In fact, the sound should not even be actively played in order to cause an error. If I just create a buffer (using DirectSound8) and never start playing, I still get these errors.

This happens on multiple PCs with several combinations of network cards (both fiber optic and RJ45) and sound cards (both integrated and individual cards). I also tried different versions of drivers for each network card and sound card. All tests were on Windows 7 32bit. Since my application uses DirectSound for audio, I tried different CooperativeLevels (normal operation of DSSCL_PRIORITY) without success.

At this point, I'm sure this has nothing to do with my application, and I was wondering if anyone had any idea what might cause this problem before I start contacting the hardware vendors and / or Microsoft

+4
source share
2 answers

Microsoft is known to have built some kind of strange anti-function in the Windows Vista kernel that will prevent I / O performance degradation to make sure that multimedia applications (Windows Media Player, directX) receive 100% responsiveness. I do not know if this also means packet loss with UDP. Read this lame rationale for the method: http://blogs.technet.com/b/markrussinovich/archive/2007/08/27/1833290.aspx

One of the comments there describes it quite well: "It seems that Microsoft tried to" fix "something that was not broken."

+1
source

Turns out this is design behavior. Windows Vista and later versions have something called the Media Class Scheduler Service (MMCSS) designed to make media playback as smooth as possible. Because multimedia playback depends on hardware interrupts to ensure smooth playback, any competing interrupts will cause problems. One of the main sources of hardware interruption is network traffic. Because of this, Microsoft decided to disable network traffic when starting the program as part of MMCSS.

I guess it was a big deal back in 2007 when Vista came out , but I missed it. There was an article by Mark Russinovich (thanks ypnos ) a description of MMCSS . It seems that my whole problem came down to the following:

Since the standard Ethernet frame size is about 1,500 bytes, the limit of 10,000 packets per second equal the maximum throughput of about 15 MB / s. 100 MB networks can handle no more than 12 MB / s, so if your system is at 100Mb, you usually won't see any slowdown. However, if you have a 1 Gbps network infrastructure and a sending system and your Vista host system has 1 Gbps adapters, you will see bandwidth up to about 15%. In addition, an unsuccessful throttling error is an NDIS code that increases throttling if you have multiple network adapters. If you have wireless and wired adapters, for example, NDIS will process no more than 8000 packets in the second, and with three adapters it will process a maximum of 6000 packets per second. 6000 packets per second is 9 MB / s, a limit that is visible even on networks with 100 MB.

I have not yet confirmed that the multiple adapter error still exists in Windows 7 or Vista SP1, but this is what you should look for if you encounter problems.

From the comments on the Russinovich post, I found that Vista SP1 introduced some registry settings that let you configure how MMCSS affects Windows. In particular NetworkThrottlingIndex key .

The solution to my problem was to completely disable network throttling by setting the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\NetworkThrottlingIndex to 0xFFFFFFFF , and then restarting the computer. This completely disables the throttling part of the MMCSS network. I tried to just increase the value to 70 , but it did not stop causing errors until I completely turned it off.

So far, I have not seen any negative consequences for other multimedia applications (as well as parts of video capture and audio output in my application). I will let you know here if that changes.

+6
source

Source: https://habr.com/ru/post/1335142/


All Articles