Skip to content

Extremely high CPU usage when piping data #18702

@ytimenkov

Description

@ytimenkov

Prerequisites

Steps to reproduce

Linux, Powershell Core 7.2.3

When I try to pass large mounts of data (an image), for example:

$ curl -L https://download.opensuse.org/distribution/leap/15.4/appliances/iso/openSUSE-Leap-15.4-CR-DVD-x86_64-Media.iso | dd of=/dev/null

(with fast internet, alternatively one may try piping xzcat's output to dd).

Expected behavior

For the similar command bash doesn't use any CPU at all.

Actual behavior

CPU usage of `pwsh` process us 150-160% (4 cores).

Error details

I understand that pwsh may read input and split into lines while bash simply does `dup2`, but maybe there could be some short-circuit if both ends of pipe operator are fed to an external process.

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Linux 6.0.8-1-default #1 SMP PREEMPT_DYNAMIC Fri Nov 11 08:02:50 UTC 2022 (1579d93)
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.Resolution-DuplicateThe issue is a duplicate.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions