Skip to content

Progress Reporting makes Invoke-RestMethod 70x slower #2238

Closed

Description

@afscrome

Steps to reproduce

#Run with progress reporting disabled
$ProgressPreference = 'SilentlyContinue'
Measure-Command {
    Invoke-RestMethod https://archive.apache.org/dist/lucene/solr/6.2.0/solr-6.2.0.zip -OutFile 2.zip
} | select TotalSeconds

#Now run with the default Progress Preference value
$ProgressPreference = 'Continue'
Measure-Command {
    Invoke-RestMethod https://archive.apache.org/dist/lucene/solr/6.2.0/solr-6.2.0.zip -OutFile 1.zip
} | select TotalSeconds

Expected behavior

I'd expect progress reporting to have a small overhead, but not a significant one

Actual behavior

$ProgressPreference = 'Continue' is about 70 times slower than 'SilentlyContinue'. (On PS 5.1 in the latest Win 10 preview it is about 120x slower)

TotalSeconds
------------
    8.471039
  589.319871

Environment data

> $PSVersionTable
Name                           Value
----                           -----
SerializationVersion           1.1.0.1
PSEdition                      Core
PSVersion                      6.0.0-alpha
WSManStackVersion              3.0
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.9
PSRemotingProtocolVersion      2.3
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
CLRVersion

Activity

  1. nightroman commented on Sep 12, 2016

    @nightroman

    It is a proper issue. But the real culprit here is probably the implementation of console host WriteProgress(). It can be improved for all cmdlets, including Invoke-RestMethod.

    https://connect.microsoft.com/PowerShell/feedback/details/337323

  2. added
    WG-Interactive-Console
    WG-Engine-Performance
    on Sep 12, 2016
  3. oising commented on Sep 12, 2016

    @oising
    Contributor

    Roman Kuzmin 1967-2026 (@nightroman) I get the point of that connect item, but it seems to be putting the onus on powershell to ignore too many calls to WriteProgress instead of - imo rightfully - blaming the caller for making too many calls :) That said, the base performance could likely be improved, absolutely.

  4. andyleejordan commented on Sep 19, 2016

    @andyleejordan
    Member

    I'm surprised that it is faster in PS 6 than in PS 5.1. Wow.

  5. SteveL-MSFT commented on Oct 16, 2016

    @SteveL-MSFT
    Member

    This is dupe of #2138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-DuplicateWG-Engine-PerformanceWG-Interactive-Console

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions