WGL调用降低了Nvidia系统上内存分配的性能

时间:2017-10-18 21:05:16

标签: windows nvidia wgl

我们的C ++应用程序遇到了严重的性能问题,在使用Nvidia显卡的某些系统上使用WGL创建窗口(以及OpenGL进行渲染)。创建窗口后,或者更准确地说,只要调用 ChoosePixelFormat SetPixelFormat ,内存分配就会在整个生命周期内显着降低。这种情况发生在我们可以访问的众多不同系统上,但最明显的是 Quadro M6000 12 GB(驱动程序版本385.69)和 Titan Xp (驱动程序版本) 387.92)在Windows 8.1 Pro 64位和Windows 10 Enterprise 64位上。在较低的程度上,这种效果对于GeForce卡和Windows 7 Professional 64位也是可测量的。

I have made a small test application demonstrating the issue.我们运行一项涉及大量内存分配的昂贵工作,然后使用WGL创建一个窗口,调用ChoosePixelFormat,删除窗口,然后再次运行相同的昂贵内存分配。内存分配是定时的并输出到控制台。在我们对所有系统进行了测试(六种不同的卡,三种操作系统),在调用ChoosePixelFormat后,内存分配可测量(在5%和20%之间)较慢。但是,当我们将Quadro或Titan Xp放入系统时,ChoosePixelFormat之后的内存分配占用了之前时间的300%以上。

一些测试结果(我们在系统之间交换卡片以覆盖几乎所有组合,但我们没有保留所有基准,但这是一个有意义的子集):

Titan Xp, Windows 8.1 Pro 64 bit

Before Window Creation
Testing memory allocation performance 1 / 3: 5.20743 seconds
Testing memory allocation performance 2 / 3: 5.60933 seconds
Testing memory allocation performance 3 / 3: 5.4247 seconds

After Window Creation
Testing memory allocation performance 1 / 3: 18.0398 seconds
Testing memory allocation performance 2 / 3: 17.9902 seconds
Testing memory allocation performance 3 / 3: 17.9052 seconds


GTX 770, Windows 7 Professional 64 bit

Before Window Creation
Testing memory allocation performance 1 / 3: 4.66427 seconds
Testing memory allocation performance 2 / 3: 4.65927 seconds
Testing memory allocation performance 3 / 3: 4.62726 seconds

After Window Creation
Testing memory allocation performance 1 / 3: 5.69533 seconds
Testing memory allocation performance 2 / 3: 5.71333 seconds
Testing memory allocation performance 3 / 3: 5.72833 seconds


GTX 1080, Windows 8.1 Pro 64 bit

Before Window Creation
Testing memory allocation performance 1 / 3: 5.35666 seconds
Testing memory allocation performance 2 / 3: 5.37008 seconds
Testing memory allocation performance 3 / 3: 5.36607 seconds

After Window Creation
Testing memory allocation performance 1 / 3: 5.7112 seconds
Testing memory allocation performance 2 / 3: 5.69939 seconds
Testing memory allocation performance 3 / 3: 5.71902 seconds

我记得有一个老技巧,我会拉上我的Optimus笔记本电脑,以便自编的应用程序自动使用离散的Nvidia GPU:将可执行文件重命名为 wow.exe 。我试过这个,当然,它有效。在我们的实际应用程序和测试应用程序中,性能问题都消失了。在Titan Xp上,调用ChoosePixelFormat之后的内存分配奇迹般地比调用它之前更快。我很确定这是因为“魔兽世界”的视频驱动程序中的特殊分支,它绕过了一些让我们的生活变得艰难的“功能”。所以现在我们可以把它称为一天并运送我们的软件名为wow.exe,但在某些时候,客户可能会问这个名字代表什么,我们必须提出一个聪明的首字母缩略词或品牌重塑。这不是一个永久的解决方案,而是一个非常奇怪的调试结果。 (“视频卡供应商不希望您知道:通过这一个简单的技巧提高3D应用程序的性能!”)

调试链接的测试应用程序时,您可以看到在窗口创建期间,一个或多个线程由窗口销毁后生存的视频驱动程序生成。我们怀疑他们在某种程度上参与了这一切。但是,我们没有时间和预算来进一步调查这一点。

除了命名我们的软件wow.exe,降级到GTX 1080s,或等待Nvidia回答我们的支持查询 - 他们四年没有做过一次 - 我们现在有什么选择?有没有人遇到并成功克服了这个问题?在Windows 7 / 8.1 / 10上使用WGL创建窗口和OpenGL(4.5核心)上下文时,有没有办法绕过ChoosePixelFormat和SetPixelFormat? (我们也尝试使用GLFW设置窗口,但我很确定这会引起WGL的注意 - 结果是一样的。)此外,我们会对有Maxwell或Pascal Quadro卡的人的评论非常感兴趣或Titan Xp谁没有遇到这些问题。也许我们的设置中的一个小改变可以解决问题。

PS:虽然这个问题听起来有点奇怪,但我们并不是第一个遇到它的人。 It has been described before,但显然,Nvidia没有时间回答或解决这个问题。

0 个答案:

没有答案
相关问题