Skip to content

Invoke-Webrequest very slow in Powershell 7 compared to 6 and 5.1 #17762

Closed

Description

Prerequisites

Steps to reproduce

I am experiencing a performance issue with Invoke-Webrequest on PS 7.3.0-preview.6, compared to PS version 5.1 and 6 tested on Windows 10 and OSX.

Can be reproduced with the example URL below.
On PS 5.1 and 6 you get a return value after 1-2 seconds.
With PS 7 it takes around 70-80 seconds.

Reproducible on Windows 10 and OSX.
Please also see comparison videos.

Expected behavior

Invoke-WebRequest "https://www.libro.at/legor-30464-el-fuegos-stunt-kanone-polybag-30464-5702016668247.html" -Verbose
VERBOSE: GET https://www.libro.at/legor-30464-el-fuegos-stunt-kanone-polybag-30464-5702016668247.html
with 0-byte payload
VERBOSE: received 2586741-byte response of content type text/html

get a return value after 1-2 seconds

Actual behavior

Invoke-WebRequest "https://www.libro.at/legor-30464-el-fuegos-stunt-kanone-polybag-30464-5702016668247.html" -Verbose
VERBOSE: HTTP/1.1 GET with 0-byte payload
VERBOSE: received 2586741-byte response of content type text/html

get a return value after 70-80 seconds

Error details

Performance on PS7 is very slow compared to PS5.1 and PS6

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0-preview.6
PSEdition                      Core
GitCommitId                    7.3.0-preview.6
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

https://www.youtube.com/watch?v=pNeat9bDuoQ

https://www.youtube.com/watch?v=qW3Bsr8ElsE

Activity

  1. added
    Needs-Triage
    on Jul 24, 2022
  2. iSazonov commented on Jul 25, 2022

    @iSazonov
    Collaborator

    The issue appeared after moving to .Net 7.0.

    /cc Steve Lee (@SteveL-MSFT) for information.

  3. NoMoreFood commented on Jul 25, 2022

    @NoMoreFood
    Contributor

    Stefan Schmidhammer (@Terr4) Is this issue consistent across common MIME types for you? I am able to reproduce this, but not when -OutFile is used so I'm guessing it's slowing down in the post-processing of the data.

  4. Terr4 commented on Jul 25, 2022

    @Terr4
    Author

    Stefan Schmidhammer (@Terr4) Is this issue consistent across common MIME types for you? I am able to reproduce this, but not when -OutFile is used so I'm guessing it's slowing down in the post-processing of the data.

    I am only working with text/html responses, so unfortunately I cannot comment on other filetypes, but I also expected the postprocessing as the culprit so I tried -UseBasicParsing but without success.

    I can confirm that it works very fast with -OutFile also on my side!

    Just a note: The test url is not my server, so it can be that they do something to prevent such requests. However although it works very fast with versions PS5.1 and PS6

  5. SteveL-MSFT commented on Aug 1, 2022

    @SteveL-MSFT
    Member

    This is quite interesting. Trying it out I see that the progress bar indicates the content is received and then it hangs for a bit before returning the result. Need to investigate what is happening between that time.

  6. SteveL-MSFT commented on Aug 1, 2022

    @SteveL-MSFT
    Member

    Looks like the problem is that URL returns a large HTML page and the cmdlet is using a regex to try and find the charset. This takes a long time. I'm going to see if I can find an optimization.

  7. ghost added
    In-PR
    on Aug 1, 2022
  8. ghost removed
    In-PR
    on Aug 22, 2022
  9. ghost added
    Resolution-Fixed
    on Aug 22, 2022
  10. ghost removed
    Needs-Triage
    on Aug 22, 2022
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-FixedWG-CmdletsWaiting - DotNetCore

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions