gpt4 book ai didi

performance - 第一次查询 WMI 性能计数器时出现奇怪的延迟

转载 作者:行者123 更新时间:2023-12-04 03:19:48 24 4
gpt4 key购买 nike

我正在查询 WMI(win32_perfrawdata_perfproc_process 类)并且发生了一些奇怪的事情:第一次查询它时,它停止了近 50 秒以显示答案。下一次几乎是立即的。

有没有人看到这种行为?有什么可以避免的吗?

要重现这一点,请打开 Powershell 窗口并键入

gwmi win32_perfrawdata_perfproc_process

第一次运行此命令时,它会停止近 50 秒。第二次几乎是立即的。

布鲁诺

最佳答案

六年后回答这个问题是否为时已晚? :)

第一个 WMI 查询(来自任何来源,powershell、wmic 命令行,或通过 COM 调用以编程方式)的大约 20 秒延迟是正常的。我已经追踪到 RPC/TCP 连接。根据 Windows documentation :

Starting with Windows Vista, the service control manager (SCM) supports remote procedure calls over both Transmission Control Protocol (RPC/TCP) and named pipes (RPC/NP). Client-side SCM functions use RPC/TCP by default.

RPC/TCP is appropriate for most applications that use SCM functions remotely, such as remote administration or monitoring tools. However, for compatibility and performance, some applications might need to disable RPC/TCP by setting the registry values described in this topic.

When a service calls a remote SCM function, the client-side SCM first attempts to use RPC/TCP to communicate with the server-side SCM. If the server is running a version of Windows that supports RPC/TCP and allows RPC/TCP traffic, the RPC/TCPP connection will succeed. If the server is running a version of Windows that does not support RPC/TCP, or supports RPC/TCP but is operating behind a firewall which allows only named pipe traffic, the RPC/TCP connection times out and the SCM retries the connection with RPC/NP. This will succeed eventually but can take some time (typically more than 20 seconds), causing the OpenSCManager function to appear blocked.



上面的链接指定了可以更改以消除此延迟的注册表值。他们在 HKLM\SYSTEM\CurrentControlSet\Control 下.通过更改 SCMApiConnectionParam,我已经能够将延迟缩短到仅 5 秒。超时值设置为 5000。

关于performance - 第一次查询 WMI 性能计数器时出现奇怪的延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15743477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com