You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invoke-Webrequest very slow in Powershell 7 compared to 6 and 5.1 #17762
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" -VerboseVERBOSE: GET https://www.libro.at/legor-30464-el-fuegos-stunt-kanone-polybag-30464-5702016668247.htmlwith 0-byte payloadVERBOSE: received 2586741-byte response of content type text/htmlget 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" -VerboseVERBOSE: HTTP/1.1 GET with 0-byte payloadVERBOSE: received 2586741-byte response of content type text/htmlget 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
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.
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
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.
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.
Activity
iSazonov commentedon Jul 25, 2022
The issue appeared after moving to .Net 7.0.
/cc Steve Lee (@SteveL-MSFT) for information.
NoMoreFood commentedon Jul 25, 2022
Stefan Schmidhammer (@Terr4) Is this issue consistent across common MIME types for you? I am able to reproduce this, but not when
-OutFileis used so I'm guessing it's slowing down in the post-processing of the data.Terr4 commentedon Jul 25, 2022
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
SteveL-MSFT commentedon Aug 1, 2022
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.
SteveL-MSFT commentedon Aug 1, 2022
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.