Welcome › Forums › General PowerShell Q&A › Optimizing HW and OS for powershell performance
- This topic has 3 replies, 3 voices, and was last updated 1 month ago by
Participant.
-
AuthorPosts
-
-
December 13, 2020 at 4:47 am #279207
Hello.
I was looking for some articles about optimizing HW and OS for PowerShell performance, I always end up with articles about optimizing PowerShell code. I do not argue with the need of optimizing the code. But is there a way how to also optimize HW and OS (system variables?) to make PowerShell run as optimized as possible? An example:
I am processing IIS logs and I need to do combination without repetition. I tried to simplify the code to keep the idea without sending unnecessary code ($collection1 and $collection2 are the same):
PowerShell12345678910foreach ($collrow1 in $collection1) {$ip1 = $collrow1.cip$collection2.RemoveAt(0)foreach ($collrow2 in $collection2) {$ip2 = $collrow2.cipif ($ip1 -eq $ip2) {....}}}I tried using workflow and foreach -paralel
PowerShell12345678910foreach ($collrow1 in $collection1) {$ip1 = $collrow1.cip$collection2.RemoveAt(0)<strong>foreach -parallel</strong> ($collrow2 in $collection2) {$ip2 = $collrow2.cipif ($ip1 -eq $ip2) {....}}}The results were tragic. The output was the same = both versions produced same result, same data. But that “optimized” version ran 10 times longer. It actually makes sense. The system was Windows Server 2019 running in Hyper-V with single vCPU. I just made things worse. I am going to add vCPU so that system runs 16 vCPU. But I have no idea if it helps, or it is too much and useless. Does PowerShell really use it?
I am also trying to chew this article:
It goes slowly because I am not a programmer.
But my question is: I have Windows Server 2019 with 16CPU, 32GB RAM, almost no applications running. Can I do anything with the OS or HW to make PowerShell run faster?
Thank you
Honza
-
December 13, 2020 at 10:28 am #279231
If I understand correctly, you want to combine IIS logs and search the logs for a string? Give an example of what you want the output to look like.
-
December 14, 2020 at 12:16 pm #279552
No, I just need to know if there are any recommendations regarding HW and OS. Something like:
Use as much CPU as possible or do not use more than X cores, because …Use as much RAM as possible or do not use more than X because …
Set this ENV variable to allow best PowerShell performance …
Does anything like this exist?
-
-
December 14, 2020 at 5:38 pm #279627
Not sure there are performance setting for Powershell per se and typically performance is totally a ‘it depends’. If we wanted to multi-threading, we would test and see how many threads a system can handle, but this would depend on what you’re doing. If you were performing multiple transactions against something like Exchange or API’s, you’re going to hit a login limit or throttling. Outside of that, having the latest versions typically have security and performance upgrades. My .02
-
-
AuthorPosts
- You must be logged in to reply to this topic.