Powershell:最大是多少? Foreach-Object -Parallel 的 Throttlelimit 值?
我有 100 万个项目需要使用 Powershell 检查。为了提高性能,我想使用 ForEach-Object -Parallel
。为此,我部署了一个非常强大的VM。
运行空间池大小由 ThrottleLimit 参数指定。 默认运行空间池大小为 5。您仍然可以创建新的 使用 UseNewRunspace 开关为每次迭代提供运行空间。
我注意到无论我将限制设置多高,CPU 使用率都不会增加。该参数有技术上的最大限制吗?我的印象是,超过某个值,限制就会受到限制。
$oneMillionItems | ForEach-Object -Parallel {
Do something ...
} -Throttlelimit 300
PS > $PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I have 1 Million Items to check with Powershell. To improve the performance, I want to use ForEach-Object -Parallel
. For this reason, I have deployed a very powerful VM.
The runspace pool size is specified by the ThrottleLimit parameter.
The default runspace pool size is 5. You can still create a new
runspace for each iteration using the UseNewRunspace switch.
I notice that no matter how high I set the limit, the CPU usage does not increase. Is there a technical maximum limit for this parameter? I have the impression that above a certain value the limit is simply capped.
$oneMillionItems | ForEach-Object -Parallel {
Do something ...
} -Throttlelimit 300
PS > $PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论