Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipes between native processes are too slow #2176

Closed
jhclark opened this issue Sep 3, 2016 · 4 comments
Closed

Pipes between native processes are too slow #2176

jhclark opened this issue Sep 3, 2016 · 4 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-Duplicate The issue is a duplicate. WG-Engine core PowerShell engine, interpreter, and runtime

Comments

@jhclark
Copy link

jhclark commented Sep 3, 2016

Problem: Native (non-object) pipes between native processes are ~1000X faster versus PowerShell object pipes. This is especially problematic for us systems people who like to work on 500MB-5GB files routinely.

Proposed solution: Automatically detect 2 native processes (neither is a function nor commandlet), and use a direct system pipe.

Timings from my box:

  1. Powershell object pipe
PS> time { cat bigfile.txt | measure -line }
Minutes           : 15
Seconds           : 14
TotalSeconds      : 914.4296154
  1. Using cygwin utilities
PS> time { FastPipe { C:\cygwin\bin\cat.exe bigfile.txt | c:\cygwin\bin\wc -l } }
TotalSeconds      : 1.7950218

*FastPipe is a hack I wrote that stringifies the scriptblock and passes it to cmd.exe for its faster raw pipes. Perhaps this is the best solution for now?

@jhclark jhclark changed the title Pipes between natives processes are too slow Pipes between native processes are too slow Sep 3, 2016
@GeeLaw
Copy link

GeeLaw commented Sep 5, 2016

No. There is NOT pipes between native commands.

When invoking a native command, PowerShell runs the command, interprets the stdout of it and make it a typed output.

If you are sending an object to a native command, PowerShell outputs it into the stdin of that command.

With those two combined, if you do native | native on PowerShell, PowerShell will "help" you corrupt the stdout of the first native and of course, the stdin of the second native.

Use Start-Process or System.Diagnostics.Process to invoke native commands.

@jhclark
Copy link
Author

jhclark commented Sep 5, 2016

I am aware that this is not the current implementation and that is what I would like changed.

The object in the middle model makes sense for functions and commandlets, but not native processes, both in terms of efficiency and possible data corruption.

If you believe this is a feature and not a deficiency, could you provide a concrete user case?

Get Outlook for Android

On Mon, Sep 5, 2016 at 12:07 AM -0700, "Gee Law" notifications@github.com wrote:

No. There is NOT pipes between native commands.

When invoking a native command, PowerShell runs the command, interprets the stdout of it and make it a typed output.

If you are sending an object to a native command, PowerShell outputs it into the stdin of that command.

With those two combined, if you do native | native on PowerShell, PowerShell will "help" you corrupt the stdout of the first native and of course, the stdin of the second native.

Use Start-Process or System.Diagnostics.Process to invoke native commands.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@GeeLaw
Copy link

GeeLaw commented Sep 5, 2016

I don't believe that this is a useful feature. There is already an issue addressing this. See #559. This issue is mostly a duplicate/sunset of that issue.


And do note my sarcasm on this "smart oo pipe between native utilities", I said PS "helped" you currput the streams.

@joeyaiello joeyaiello added Resolution-Duplicate The issue is a duplicate. Issue-Enhancement the issue is more of a feature request than a bug WG-Engine core PowerShell engine, interpreter, and runtime labels Sep 5, 2016
@jhclark
Copy link
Author

jhclark commented Sep 6, 2016

I could go for better language than "this is not a useful feature" -- I'm quite certain that it is.

However, I do buy that it is a duplicate of #1908, which appears to be discussed in #559 now and actively worked on by @vors on the PowerShell team.

@jhclark jhclark closed this as completed Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-Duplicate The issue is a duplicate. WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

No branches or pull requests

3 participants