Skip to content

PSNativeCommandPreserveBytePipe's performance issues #26101

@dt-flo

Description

@dt-flo

Prerequisites

Steps to reproduce

Issue 1908 and pull request 17857 are about the feature PSNativeCommandPreserveBytePipe which introduces the ability to pipe binary data stream from one native application to another.

This feature works, however, I encounter significantly lower speeds when using PowerShell to chain two native applications in comparison to the speed when using other shells like Bash on Linux or cmd.exe on Windows.

To reproduce the issue, take any file, and use dd to read the file and pipe it to dd again to write it to the disk by using the command
dd if=inputfile bs=1MB | dd of=outputfile bs=1MB.

Expected behavior

dd should report the same speeds as if it was used in Bash or cmd.exe

Actual behavior

The speed is significantly reduced. The following tests are executed in an Ubuntu VM on an SSD drive.

Bash:

user@ubuntu:/tmp$ dd if=dotnet-sdk-9.0.305-win-x64.exe bs=1MB | dd of=dotnetout bs=1MB
226+1 records in
226+1 records out
226741024 bytes (227 MB, 216 MiB) copied, 0.988518 s, 229 MB/s
0+3588 records in
0+3588 records out
226741024 bytes (227 MB, 216 MiB) copied, 0.98907 s, 229 MB/s

PowerShell 7:

user@ubuntu:/tmp$ pwsh
PowerShell 7.5.3
PS /tmp> dd if=dotnet-sdk-9.0.305-win-x64.exe bs=1MB | dd of=dotnetout bs=1MB
226+1 records in
226+1 records out
226741024 bytes (227 MB, 216 MiB) copied, 1.68791 s, 134 MB/s
0+106333 records in
0+106333 records out
226741024 bytes (227 MB, 216 MiB) copied, 1.93509 s, 117 MB/s
PS /tmp>

In visuals, I have provided a screenshot of some tests I did in a freshly installed Debian 12 VM running in Hyper-V.
The drive was an NVMe SSD.

Error details

N/A

Environment data

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Ubuntu 24.04.3 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS >

Visuals

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Engine-Performancecore PowerShell engine, interpreter, and runtime performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions